Advertisement
Guest User

Untitled

a guest
Mar 30th, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.38 KB | None | 0 0
  1. public SLL onlyEvenPos() {
  2.     SLL evenPosition = new SLL();
  3.     SLLNode current = root.next;
  4.     SLLNode last = root;
  5.     int br = 0;
  6.     while(current != null) {
  7.       br++;
  8.       if(br % 2 == 0) {
  9.         evenPosition.addToEnd(current.value);
  10.         last.next = current.next;
  11.       }
  12.       last = current;
  13.       current = current.next;
  14.     }
  15.     return evenPosition;
  16.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement