[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"searchBlogPosts":3,"$f6RbgzW-2r90j9QiE7BPmk2Ap9jmptpJ_rFMw92rOges":7},[4],{"_path":5,"title":6},"\u002Fblog\u002F2023\u002F09\u002F17\u002Fspring-boot-postgresql","Spring Boot with PostgreSQL & pgAdmin in Docker",{"title":8,"category":9,"problemHtml":10,"solutions":11,"repoUrl":20},"Reverse A Linked List","Data Structures & Algorithms","",[12,16],{"lang":13,"label":14,"html":15},"java","Java","\u003Cpre>\u003Ccode class=\"language-java\">\u002F**\n * Definition for singly-linked list.\n * public class ListNode {\n *     int val;\n *     ListNode next;\n *     ListNode() {}\n *     ListNode(int val) { this.val = val; }\n *     ListNode(int val, ListNode next) { this.val = val; this.next = next; }\n * }\n *\u002F\n\nclass Solution {\n    public ListNode reverseList(ListNode head) {\n        if (head == null)\n            return null;\n        \n        ListNode prev = null, curr = head;\n\n        while(curr != null) {\n            ListNode temp = curr.next;\n            curr.next = prev;\n            prev = curr;\n            curr = temp;\n        }\n\n        return prev;\n    }\n}\u003C\u002Fcode>\u003C\u002Fpre>",{"lang":17,"label":18,"html":19},"python","Python","\u003Cpre>\u003Ccode class=\"language-python\"># Definition for singly-linked list.\n# class ListNode:\n#     def __init__(self, val=0, next=None):\n#         self.val = val\n#         self.next = next\n\n\nclass Solution:\n    def reverseList(self, head: Optional[ListNode]) -&gt; Optional[ListNode]:\n        if not head:\n            return None\n\n        newhead = head\n\n        if head.next:\n            newhead = self.reverseList(head.next)\n            head.next.next = head\n\n        head.next = None\n\n        return newhead\u003C\u002Fcode>\u003C\u002Fpre>","https:\u002F\u002Fgithub.com\u002Fvishwarajsali\u002FInterviewPrep\u002Ftree\u002Fmain\u002FData%20Structures%20%26%20Algorithms%2Freverse-a-linked-list"]