First Thoughts: create helper method to return length of given linked list. In main solution method, calculate middle index by dividing length plus one. Traverse the input linked list and if its "index" is equal to middle index, return head (return type is list node)
My Solution:
class Solution {
public ListNode reverseList(ListNode head) {
ListNode reversed = null;
while (head!=null) {
reversed = new ListNode(head.val, reversed);
head = head.next;
}
return reversed;
}
}