We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 78dbc99 commit d82b458Copy full SHA for d82b458
src/chapter03linkedlists/LinkedList.java
@@ -115,13 +115,17 @@ public synchronized ListNode removeFromEnd() {
115
ListNode p = head, q = null, next = head.getNext();
116
if (next == null) {
117
head = null;
118
+ // reduce the length of the list
119
+ length-=1;
120
return p;
121
}
122
while((next = p.getNext()) != null) {
123
q = p;
124
p = next;
125
126
q.setNext(null);
127
128
129
130
131
0 commit comments