I am getting the correct answer-, but it is not accepting all the test cases.
i cant even access the test cases and editorial.
LL - k Reverse java
Hi Aman
Please share the link to your code.
Hi Aman,
Your code will not work for k > 3 as you are only reversing the first and kth element. Suppose k = 4 is given and linked list is 9 -> 4 ->1 ->7 ->8 -> 6 -> 5 ->3 then the output will be 7 -> 1 -> 4 ->9 -> 3 -> 5 -> 6 -> 8 but your code will give output 7 -> 4 -> 1 ->9 -> 3 -> 6 -> 5 -> 8
1 Like
thanks- that solved it
Hi Aman
I am marking your doubt as resolved. In future, please mark your doubts as resolved in your course’s “ Ask Doubt ” section, when your doubt is resolved.