from typing import List class Solution: def searchInsert(self, nums: List[int], target: int) -> int: for index, ele in enumerate(nums): if target <= ele: return index return len(nums) def main(): s = Solution() print(s.searchInsert([1,3,5,6], 5)) # 2 print(s.searchInsert([1,3,5,6], 2)) # 1 print(s.searchInsert([1,3,5,6], 7)) # 4 print(s.searchInsert([1,3,5,6], 0)) # 0 if __name__ == '__main__': main()