문제링크
풀이1
class Solution {
fun searchInsert(nums: IntArray, target: Int): Int {
var start = 0
var end = nums.size - 1
while (start <= end) {
val mid = (start + end) / 2
if (nums[mid] == target) return mid
else if (nums[mid] > target) end = mid - 1
else start = mid + 1
}
return start
}
}