/** * 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) { ListNode *P=0,*T=0; P=head; if(head){ T=head->next; }else return false; while(P!=T){ P=P->next; i...