Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- 해물감성포차
- invert Binary Tree
- findDulicate
- tree
- 알고리즘
- 른당사피
- Array
- string
- 알탕뚝배기
- 투포인터
- LeetCode
- 6월 첼린지
- 코딩 테스트
- two pointers
- algorithm
- 발리인망원
- algorithum
- Find the Duplicate Number
- two sum
- 망원 밥집
- 맛집
- 코딩 테세트
- java
- map
- Python
- 사당돈
- 코테
- linked list
- 발리 음식
- prefix sum
Archives
- Today
- Total
기록하는 공간
[leetcode/kotlin] 35.Search Insert Position 본문
class Solution {
fun searchInsert(nums: IntArray, target: Int): Int {
var low = 0
var high = nums.size - 1
while (low <= high) {
var mid = (low + high) / 2
if (nums[mid] == target) {
return mid
}
if (target < nums[mid]) {
high = mid - 1
} else {
low = mid + 1
}
}
return low
}
}
'알고리즘 > leetcode' 카테고리의 다른 글
[leetcode/kotlin] 290.Word pattern (0) | 2020.09.08 |
---|---|
[leetcode/kotlin] 118. Pascal's Triangle (0) | 2020.08.24 |
[leetcode/kotlin] 392.Is Subsequence (0) | 2020.06.09 |
[leetcode/kotlin] 344. Reverse String (0) | 2020.06.04 |
[leetcode/java] 226. Invert Binary Tree (0) | 2020.06.01 |
Comments