MCPcopy Create free account
hub / github.com/apna-college/Alpha / removeLast

Method removeLast

12_LinkedList.java/LL.java:82–102  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

80 }
81
82 public int removeLast() {
83 if(size == 0) {
84 System.out.println("empty LL");
85 return Integer.MIN_VALUE;
86 } else if(size == 1) {
87 int val = head.data;
88 head = tail = null;
89 size = 0;
90 return val;
91 }
92
93 Node temp = head;
94 for(int i=0; i<size-2; i++) {
95 temp = temp.next;
96 }
97 int val = temp.data;
98 temp.next = null;
99 tail = temp;
100 size--;
101 return val;
102 }
103
104 //Iterative
105 public int itSearch(int key) {

Callers 1

popMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected