Skip to content

Commit

Permalink
Time: 11 ms (64.23%), Space: 8.1 MB (77.98%) - LeetHub
Browse files Browse the repository at this point in the history
  • Loading branch information
Dipendra-Raghav committed May 4, 2023
1 parent 30774c8 commit adf8d65
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions 0141-linked-list-cycle/0141-linked-list-cycle.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode(int x) : val(x), next(NULL) {}
* };
*/
class Solution {
public:
bool hasCycle(ListNode *head) {
while(head!=NULL)
{
if(head->val==INT_MIN)return true;
head->val=INT_MIN;
head=head->next;
}
return false;
}
};

0 comments on commit adf8d65

Please sign in to comment.