leetcode/include/s0142_linked_list_cycle.hpp

21 lines
370 B
C++
Raw Normal View History

2022-12-02 11:12:03 +00:00
#ifndef S0142_LINKED_LIST_CYCLE_HPP
#define S0142_LINKED_LIST_CYCLE_HPP
#include <unordered_map>
2023-01-30 12:17:47 +00:00
#include "structures.hpp"
2022-12-02 11:12:03 +00:00
struct IterResult {
ListNode *node;
bool meet;
};
class S0142 {
public:
std::unordered_map<ListNode *, int> footprint;
2023-01-30 12:17:47 +00:00
IterResult iter(ListNode *fast, ListNode *slow, bool startUp);
2022-12-02 11:12:03 +00:00
ListNode *detectCycle(ListNode *head);
};
#endif