HTMLify

LeetCode - Search Insert Position - Go
Views: 36 | Author: abh
func searchInsert(nums []int, target int) int {
    for i, v := range nums {
        if target <= v {
            return i
        }
    }
    return len(nums)
}

Comments

abh 2025-03-16 15:26

I didn't expect this to be solved by a linear approach -_-