This commit is contained in:
Electrominch
2022-10-07 00:48:48 +03:00
parent 0b88604037
commit e711e64e07
18 changed files with 45 additions and 45 deletions

View File

@@ -4,16 +4,16 @@ public class Solution
{
public ListNode? DetectCycle(ListNode head)
{
if(head == null)
if (head == null)
return null;
ListNode? cur = head;
int bit = 1 << 28;
int curAbs = 0;
while (cur!=null && (curAbs & bit) == 0)
while (cur != null && (curAbs & bit) == 0)
{
cur.val ^= bit;
cur = cur.next;
if(cur != null)
if (cur != null)
curAbs = cur.val < 0 ? (cur.val * -1) : cur.val;
}
cur = head;