• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests
September 13, 2023 |170 Views
SDE Sheet - Detect Loop in Linked list
  Share   Like
Description
Discussion

This video is part of the Linked List section in the GFG SDE Sheet.

In this video, given a linked list of N nodes. The task is to check if the linked list has a loop. Linked list can contain self loop.

Example :

Input:
N = 3
value[] = {1,3,4}
x(position at which tail is connected) = 2

Output: True

Explanation: In above test case N = 3. The linked list with nodes N = 3 isgiven. Then value of x=2 is given whichmeans last node is connected with xth node of linked list. Therefore, there exists a loop.

Try it out before watching the implementation of the problem in the video. We recommend watching the video, even if you can solve the problem. You may discover something new. All the best!!!

Do check out:-

Article: https://www.geeksforgeeks.org/detect-loop-in-a-Linked-list/
Problem: https://practice.geeksforgeeks.org/problems/detect-loop-in-linked-list/1
SDE Sheet: https://www.geeksforgeeks.org/sde-sheet-a-complete-guide-for-sde-preparation/

Read More