Skip to content

Commit dae5222

Browse files
committed
solution for: search insert position
1 parent 8fca8ee commit dae5222

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/leetcode/SearchInsertPosition.java

+12-12
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@ public static void main(String[] args){
77
}
88

99
public int searchInsert(int[] nums, int target) {
10-
int l=0, h=nums.length-1;
11-
while(l<h){
12-
int mid = (l+h)/2;
13-
if(target> nums[mid]){
14-
l = mid+1;
15-
}else{
16-
h=mid;
17-
}
18-
}
19-
return h;
20-
21-
}
10+
int l=0, h=nums.length-1;
11+
while(l<h){
12+
int mid = (l+h)/2;
13+
if(target> nums[mid]){
14+
l = mid+1;
15+
}else{
16+
h=mid;
17+
}
18+
}
19+
return h;
20+
21+
}
2222
}

0 commit comments

Comments
 (0)