Skip to content

Commit b3dc2a0

Browse files
committed
No need to sort
1 parent c86b201 commit b3dc2a0

1 file changed

Lines changed: 2 additions & 7 deletions

File tree

two-sum/dohyeon2.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,12 @@ public int[] twoSum(int[] nums, int target) {
2121
boolean indexExists = index != null;
2222
boolean indexExistsAndIndexIsNotTheNum = indexExists && i != index;
2323
if (indexExistsAndIndexIsNotTheNum) {
24-
// Manual sort
25-
if (i < index) {
26-
return new int[] { i, index };
27-
} else {
28-
return new int[] { index, i };
29-
}
24+
return new int[] { i, index };
3025
}
3126
}
3227

3328
// If the valid answer is always exists this is not needed
3429
// But the compiler don't know about that
3530
return new int[2];
3631
}
37-
}
32+
}

0 commit comments

Comments
 (0)