Coding-ninjas-data-st.-through-java
Coding-ninjas-data-st.-through-java copied to clipboard
I have made the necessary changes....please have a look and approve it:)
giving error, modifed codes
current code is giving error, modified code is working perfectly
Please correct the runtime error.
The previous code have an error in it. so please check the new code
Old code was giving runtime error in test case 3
Less lines of code,passed all the test cases. I think better than previous solution in time complexsity.
if( head==null ){ // base case1 return head; } if( i==j ){ // base case 2 return head; }
public class Solution { public static LinkedListNode swap_nodes(LinkedListNode head,int i,int j) { if(head==null){ // base case 1 return head; } if(i==j){ // base case 2 return head; } LinkedListNode temp=head,prev=null,c1=null,c2=null,p1=null,p2=null;...