Linked List Cycle

 

141. Linked List Cycle

Solutions

  1. Solution 1: Use set to memorize visited node.
    • Extra space
  2. Solution 2: Make visited node pointed to itself.
    • No extra space
    • Break original structure