Detect and Remove Loop from a linked list

Given a linked list which contains some loop.

You need to find the node, which creates a loop, and break it by making the node point to NULL.

INPUT

3 -> 2 -> 4 -> 5 -> 6
          ^         |
          |         |    
          - - - - - -

OUTPUT

3 -> 2 -> 4 -> 5 -> 6 -> NULL
NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a doubt? Checkout Sample Codes for more details.
Start solving Detect and Remove Loop from a linked list on Interview Code Editor
Sign Up
to access hints and editorial solutions for Detect and Remove Loop from a linked list

Discussion


Loading...
Click here to start solving coding interview questions