Back to the 100
Course Practice
Easy

Linked List Cycle

LAB

Given values and pos where the tail points back, return true if the encoded linked list has a cycle.

EXAMPLES

Example 1
Input
{
  "values": [
    3,
    2,
    0,
    -4
  ],
  "pos": 1
}

Output
true

FUNCTION SHAPE

values: intArraypos: intbool
00:00
3 local tests readyRun with ⌘/Ctrl + Enter. Your code stays in this browser.

Runs solve(...) locally in a browser worker. SWE Playbook does not submit your code. Only run code you trust; Python code may access the network.