Deletion and Reverse in Circular Linked List | GFG POTD 4th Oct 2024 | JAVA | C++

  Рет қаралды 153

CodeCraft

CodeCraft

Күн бұрын

#gfgpotd #gfgproblemoftheday #gfgtoday #gfgpotdtoday #potd #potdgfg #potdgfgtoday #problemoftheday #gfgstreek

Пікірлер: 2
@codeCraft9
@codeCraft9 Ай бұрын
C++ Code : * reverse(Node* head) { // code here if (head == nullptr || head->next == head) return head; Node* prev = nullptr; Node* curr = head; do { Node* next = curr->next; curr->next = prev; prev = curr; curr = next; } while (curr != head); head->next = prev; return prev; } // Function to delete a node from the circular linked list Node* deleteNode(Node* head, int key) { // code here if (head == nullptr || (head->next == head && head->data == key)) return nullptr; if (head->data == key) { Node* temp = head; while (temp->next != head) temp = temp->next; temp->next = head->next; return head->next; } Node* curr = head; do { if (curr->next->data == key) { curr->next = curr->next->next; break; } curr = curr->next; } while (curr != head); return head; }
@codeCraft9
@codeCraft9 Ай бұрын
JAVA Code : Node reverse(Node head) { // code here if(head == null || head.next == head){ return head; } Node curr = head; Node prev = null; do{ Node next = curr.next; curr.next = prev; prev = curr; curr = next; }while(curr != head); head.next = prev; return prev; } // Function to delete a node from the circular linked list Node deleteNode(Node head, int key) { // code here if(head == null || head.next == head && head.data == key){ return null; } if(head.data == key){ Node curr = head; while(curr.next != head){ curr = curr.next; } curr.next = head.next; return curr.next; } else{ Node curr = head; do{ if(curr.next.data == key){ curr.next = curr.next.next; break; } curr = curr.next; }while(curr != head); return head; } }
Armstrong Numbers | GFG POTD 14 June 2024 | JAVA | C++
3:59
За кого болели?😂
00:18
МЯТНАЯ ФАНТА
Рет қаралды 3 МЛН
Players vs Pitch 🤯
00:26
LE FOOT EN VIDÉO
Рет қаралды 133 МЛН
Minimum sum | GFG POTD 9 Nov 2024 | JAVA | C++
25:35
CodeCraft
Рет қаралды 207
Coding Unbreakable Encryption in C | One-Time Pad
17:42
HirschDaniel
Рет қаралды 4,5 М.
Mastering If-Else If & Nested If in Java | Java Series for Beginners
14:04
Next Permutation | GFG POTD 19 Nov 2024 | JAVA | C++
13:29
Reverse a Single Linked List
11:57
Neso Academy
Рет қаралды 280 М.
2.18 Reverse a Circular Linked List | Data Structure Tutorials
17:32
Jenny's Lectures CS IT
Рет қаралды 83 М.
За кого болели?😂
00:18
МЯТНАЯ ФАНТА
Рет қаралды 3 МЛН