Grokking Data Structures & Algorithms for Coding Interviews
Ask Author
Back to course home

0% completed

Vote For New Content
Anand Nageshwar Kumar
Using Recursion, Time O(n), Space O(1)

Anand Nageshwar Kumar

Apr 26, 2024

public ListNode swapPairs(ListNode head) {         if(head == null || head.Next == null)         return head;         var temp = head.Next;         head.Next = swapPairs(head.Next.Next);         temp.Next = head;         return temp;         }

1

0

Comments
Comments

On this page