We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5f7c512 commit 170fdf1Copy full SHA for 170fdf1
src/main/java/com/fishercoder/solutions/_704.java
@@ -41,7 +41,13 @@ public int search(int[] nums, int target) {
41
right = mid - 1;
42
}
43
44
- return nums[left] == target ? left : (right >= 0 && nums[right] == target) ? right : -1;
+ if (left <= nums.length && nums[left] == target) {
45
+ return left;
46
+ }
47
+ if (right >= 0 && nums[right] == target) {
48
+ return right;
49
50
+ return -1;
51
52
53
0 commit comments