Java icon indicating copy to clipboard operation
Java copied to clipboard

[FEATURE REQUEST] Add Swap Nodes in Pairs Problem in recursion .

Open Shreya-1305 opened this issue 1 year ago • 2 comments

What would you like to Propose?

A solution which can be understood by all.

Issue details

Given a linked list, swap every two adjacent nodes and return its head. You must solve the problem without modifying the values in the list's nodes (i.e., only nodes themselves may be changed.

class Solution { public ListNode swapPairs(ListNode head) { if(head==null) return head; ListNode temp1=head; ListNode temp2=head; temp1=temp1.next; if(temp2.next!=null) temp2.next=swapPairs(temp2.next.next); if(temp1!=null){ temp1.next=temp2; head=temp1;} return head; } }

Additional Information

No response

Shreya-1305 avatar Oct 07 '24 14:10 Shreya-1305

@siriak Please assign me this issue. I want to add this to recursion sectio n

Shreya-1305 avatar Oct 07 '24 14:10 Shreya-1305

@siriak Please assign this issue to I am interested to work on this.

Taranpreet10451 avatar Oct 08 '24 06:10 Taranpreet10451

We don't add leetcode problems

siriak avatar Oct 09 '24 05:10 siriak

@siriak Can you please tell what problems should I add. As I want to contribute by creating a PR . Thankyou !

Shreya-1305 avatar Oct 09 '24 05:10 Shreya-1305

General computer science problems, or specific well-known algorithms like encodings, string search algorithms, graph algorithms, etc.

siriak avatar Oct 10 '24 16:10 siriak

okay! Thankyou for reply

Shreya-1305 avatar Oct 11 '24 06:10 Shreya-1305