Skip to content

Commit

Permalink
Time: 5 ms (37.04%), Space: 7 MB (89.58%) - LeetHub
Browse files Browse the repository at this point in the history
  • Loading branch information
Dipendra-Raghav committed Jul 22, 2023
1 parent ea34130 commit 3bdd35c
Showing 1 changed file with 6 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,16 @@
class Solution {
public:
ListNode* middleNode(ListNode* head) {
ListNode* fast=head;
ListNode* slow=head;
while(fast!=NULL)
ListNode* fast=head;

while(fast->next!=NULL)
{
slow=slow->next;
fast=fast->next;
if(fast!=NULL)
{
fast=fast->next;
slow=slow->next;
}

if(fast->next!=NULL) fast=fast->next;
}
return slow;

}
};

0 comments on commit 3bdd35c

Please sign in to comment.