leetcode/include/s0142_linked_list_cycle.hpp
2023-01-30 20:17:47 +08:00

21 lines
370 B
C++

#ifndef S0142_LINKED_LIST_CYCLE_HPP
#define S0142_LINKED_LIST_CYCLE_HPP
#include <unordered_map>
#include "structures.hpp"
struct IterResult {
ListNode *node;
bool meet;
};
class S0142 {
public:
std::unordered_map<ListNode *, int> footprint;
IterResult iter(ListNode *fast, ListNode *slow, bool startUp);
ListNode *detectCycle(ListNode *head);
};
#endif