SOLUTION INFO
C++ · main.cpp
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode(int x) : val(x), next(NULL) {}
* };
*/
class Solution {
public:
ListNode *detectCycle(ListNode *head) {
if(head==nullptr) return nullptr;
if(head->val == 1000000) return head;
head->val = 1000000;
return detectCycle(head->next);
}
};
SOLUTION DESCRIPTION
풀이 설명
등록된 풀이 설명이 없습니다.