### 这道题是典型的用快慢指针解决的:慢指针每次走一步,快指针每次走两步,如果它们能相遇(快指针赶上慢指针),则存在环,如果遇到了nullptr,则不存在环。 ``` // 如果存在环,则返回相遇的点,否则返回nullptr SList* meetingNode(SList *list) { // 边界条件:链表为空 if (list == nullptr) { return nullptr; } SList *slow = list; if (slow == nullptr) { return nullptr; } SList *fast = slow->m_next; while (fast != nullptr && slow != nullptr) { if (fast == slow) { return fast; } slow = slow->m_next; fast = fast->m_next; if (fast != nullptr) { fast = fast->m_next; } } // 遇到nullptr return false; } ```