MCPcopy Create free account
hub / github.com/neetcode-gh/leetcode / hasCycle

Function hasCycle

javascript/0202-happy-number.js:9–9  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

7 */
8var isHappy = (n, seen = new Set()) => {
9 const hasCycle = () => n === 1 || seen.has(n);
10 while (!hasCycle()) {
11 /* Time O(log(N)) */
12 seen.add(n); /* Space O(log(N)) */

Callers 1

isHappyFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected