public static LinkedList pairSwap(LinkedList head) {
int temp;
LinkedList start = head;
if(head==null)
return null;
else{
while(head!=null && head.next!=null){
temp = head.value;
head.value = head.next.value;
head.next.value = temp;
head = head.next.next;
}
return start;
}
No comments:
Post a Comment