We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 163db85 commit 1dbbb23Copy full SHA for 1dbbb23
DataStructures/Lists/SinglyLinkedList.java
@@ -66,13 +66,12 @@ public void deleteHead() {
66
}
67
68
/**
69
- * This method deletes an element at Nth position
70
- */
+ * This method deletes an element at Nth position
+ */
71
public void deleteNth(int position) {
72
- if (position < 0 || position > getSize()) {
+ if (position < 0 || position >= getSize()) {
73
throw new RuntimeException("position less than zero or position more than the count of list");
74
- }
75
- else if (position == 0)
+ } else if (position == 0)
76
deleteHead();
77
else {
78
Node cur = head;
0 commit comments