My iterative solution in Java: AC

  • 7

    My solution is below:

    public ListNode reverseList(ListNode head) {
        ListNode first = null;
        ListNode tail = head;
        while (tail != null) {
            ListNode tmp = tail;
            tail =;
   = first;
            first = tmp;
        return first;

    Btw, I thought there is no need to judge the NULL Pointer in my solution.

  • 0

    good solution!

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.