from typing import List


class Solution:
    def searchInsert(self, nums: List[int], target: int) -> int:
        if len(nums) == 1:
            return 1 if target > nums[0] else 0
        max = len(nums) - 1
        i = 0
        while i < max:
            if nums[i] == target:
                return i
            if target > nums[i]:
                i += 1
            if target < nums[i]:
                return i
        return i + 1 if target != nums[i] else i


sl1 = Solution()
print(sl1.searchInsert([1, 3, 5, 6], target=5))
print("---")
print(sl1.searchInsert([1, 3, 5, 6], target=2))
print("---")
print(sl1.searchInsert([1, 3, 5, 6], target=7))
print("---")
print(sl1.searchInsert([1, 3], target=1))
print("---")
print(sl1.searchInsert([1, 3], target=3))
print("---")
print(sl1.searchInsert([1], target=0))
print("---")
print(sl1.searchInsert([1], target=1))
