Linked List Random Reversal Stub [reverse_linked_list]

Why is it asking me to return ListNode[] when the todo is the reverse_linked_list says to return the head of the reversed list.

I think the breakdown task of reversed_linked_list wants you to return the head and the tail of the reversed linked list , therefore it wants you to return an array of listnodes (check and you’ll see it uses res[0] and not just res)

I returned ListNode[] but the test goes in some kind of loop.

Check your reverse linked list function , res[0] would be the head of the reversed linked list function.

Yup it has the head of the reversed list

Also make sure you have properly placed null at the end of your linked list as that could be the cause of the loop you mentioned

This is the output I am getting it gets stuck after Already up to date.

Add a input file in it , it is expecting an input there

add a --input path/to/testfile to the command you have used in the screenshot, sample tests are present in the tests folder.

Also for a general test use --run instead of --test (no need of input here)

Hey you are talking about two different functions:

// This is the function that you are expected to finish and submit. this is what will be used for the tests.
public ListNode performRandomReversal(ListNode head, int[] nums) {}

// This function is a helper function that will help you break things down into smaller pieces. You don’t have to necessarily use the same signature. You can change it to anything of your liking, it just gives you a suggestion to do it in some way. What you have in LinkedListRandomReversal would not affect the final tests. We will only evaluate against performRandomReversa()
ListNode[] res = Solution.reverse_linked_list(null);

Hope you watched the kickoff video where we talk about this specifically on how you can use these stubs. If not, its worth spending 45 minutes on that.

I have watched that I might have missed something I’ll go over it once again

Closing this topic as your issue is resolved by the mentor. If it is still not resolved, Kindly un-mark the accepted solution or create a new topic and post this question as a reference link in the description of the new topic.