Ugly Python solution harnessing node.val

  • 0
    class Solution(object):
        def reverseList(self, head):
            :type head: ListNode
            :rtype: ListNode
            if not head:
                return None
                new = ListNode(-1)
      , curr, vals = head, new, []
                while is not None:
                    vals.append (
                    curr =
                vals, i, curr = vals[::-1], 0, new
                while is not None:
          , curr, i = vals[i],, i+1

Log in to reply

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