sir the floyd cycle removal algroithm does not work for circular linked list because it always gives null list isnt it?
Sir doubt floyd cycle removal
it works for that as well, just keep a check for previous node, and make prev’s next as null
otherwise, what u can also do is keep a check that if fast becomes equal to head again then we know that it is circular and break it there
Fun fact: In one of my interviews this summer for job, I was asked the same question and solved it with floyd cycle and one of the test cases was the one that u are talking about and the interviewer deemed my soln as correct
sir can i get code for it??
there is issue in the code it is showing 10 as output why??
Look at what it is printing na, first 1 is to say that it is a cycle, second is 0 which means that when it ran second time cycle is removed, boolen values have been printed, that whether there is a cycle or not