Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public SLL onlyEvenPos() {
- SLL evenPosition = new SLL();
- SLLNode current = root.next;
- SLLNode last = root;
- int br = 0;
- while(current != null) {
- br++;
- if(br % 2 == 0) {
- evenPosition.addToEnd(current.value);
- last.next = current.next;
- }
- last = current;
- current = current.next;
- }
- return evenPosition;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement