Skip to content

Commit 0d1110a

Browse files
authored
Merge pull request TheAlgorithms#772 from abhijay94/master
Fix TheAlgorithms#771(position=size causes NullPointerException)
2 parents b33c778 + 2b83b31 commit 0d1110a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

DataStructures/Lists/SinglyLinkedList.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public void deleteHead() {
6868
* This method deletes an element at Nth position
6969
*/
7070
public void deleteNth(int position) {
71-
if (position < 0 || position > getSize()) {
71+
if (position < 0 || position >= getSize()) {
7272
throw new RuntimeException("position less than zero or position more than the count of list");
7373
} else if (position == 0)
7474
deleteHead();

0 commit comments

Comments
 (0)