We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 7eb0785 commit 9b78621Copy full SHA for 9b78621
DataStructures/Lists/DoublyLinkedList.java
@@ -116,13 +116,8 @@ public Link deleteTail() {
116
public void delete(int x) {
117
Link current = head;
118
119
- while (current.value != x) {// Find the position to delete
120
- if (current != tail) {
121
- current = current.next;
122
- } else {// If we reach the tail and the element is still not found
123
- throw new RuntimeException("The element to be deleted does not exist!");
124
- }
125
+ while (current.value != x) // Find the position to delete
+ current = current.next;
126
127
if (current == head)
128
deleteHead();
0 commit comments