Skip to content

Instantly share code, notes, and snippets.

@PantherHawk
Created December 5, 2017 03:40
Show Gist options
  • Save PantherHawk/5dd44bbe7c9651d1d62e5529603f9279 to your computer and use it in GitHub Desktop.
Save PantherHawk/5dd44bbe7c9651d1d62e5529603f9279 to your computer and use it in GitHub Desktop.

Requirements

Strategy

Advance two pointers along the linked list.

  • Pointer A moves one node at a time.
  • Pointer B moves two nodes at a time.

If there's no cycle, pointer A can never catch up to pointer B.

If there is a cycle, pointer A and pointer B will eventually land on the same node.

Justification of strategy

something-something something

Define test cases

Implementation skeleton

Actual implementation

link to a Gist or Github

Execute test cases

Big-O Analysis

Optimization (if applicable)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment