diff --git a/SparseVector.java b/SparseVector.java index 632d1e2..8ed337b 100644 --- a/SparseVector.java +++ b/SparseVector.java @@ -69,16 +69,13 @@ public class SparseVector { Node now = this.head; while (now != null && now.index < index) { - + if (now != null && now.index == index) { + return now.value; + } now = now.next; } - if (now != null && now.index == index) { - double result = now.value; - - return result; - } return 0.0; }