only 1 test case is passing
where am i wrong in this code?
Circular linked lists test cases not passing
Hello @yatin,
Your producing wrong outputs for testcases like:
1 2 3 4 5 6 1 2 3 4 -1
Expected output:
1 2 3 4 5 6
Your Output:
1
1 2 3 4 5 5 5 -1
Expected Output:’
1 2 3 4 5
Your Output:
1 2 3 4 5 5
1 2 3 4 5 -1
Expected Output:
1 2 3 4 5
Your Output:
1 2 3 4 5 -1
Hope, this would help.
Give alike, if you are satisfied.
i checked out this code of someone
sir it is passing all test cases
in this while taking input it is checked if it is already present if we found we save its address
i am not getting the concept behind this ,value could be same at 2 and 6 node also
but that doesn’t means it forms a loop!
Hello @yatin,
Can you please explain your doubt properly?
As per what i have interpreted from your doubt:
-
We are saving it’s address, so that we can point the next of last node to the saved node.
-
If you see the question, it reads that if the number starts repeating then it indicates that there is a loop, with the first repeating element as head of the loop.
Hope, this would help.
ok sir thank you got it
i won’t mind a like.
BTW, mark this doubt as resolved if you don’t have any issue regarding the same.