LinkedList Reverse
Execution time limit is 1 second
Runtime memory usage limit is 128 megabytes
Reverse a linked list.
Definition of a single linked list:
// Java class ListNode { int val; ListNode next; ListNode(int x) { val = x; next = null; } }
// C++ class ListNode { public: int val; ListNode *next; ListNode(int x) : val(x), next(NULL) {} };
Implement function reverse to reverse a linked list.
// Java ListNode reverse(ListNode head)
// C++ ListNode* reverse(ListNode *head)
Example
Submissions 1K
Acceptance rate 38%