My swift solution O(n)


  • 0
    A

    class Solution {
    func searchInsert(_ nums: [Int], _ target: Int) -> Int {
    for i in 0 ..< nums.count {
    if(target <= nums[i]) {
    return i
    }
    }
    return nums.count
    }
    }


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.