【每日一题20220509】刚好大你

def solution(nums: list, idx: int)-> int:
    # your code here
    for data in sorted(nums):
        if data > nums[idx]:
            return nums.index(data)
    return -1

assert solution([4, 1, 3, 5, 6], 0) == 3
assert solution([4, 1, 3, 5, 6], 4) == -1
assert solution([1, 3, 5, 2, 4], 0) == 3
def solution(nums: list, idx: int)-> int:
    list_idx=[nums[i] for i in range(len(nums)) if nums[i]>nums[idx]]
    if len(list_idx)>0:
        return nums.index(min(list_idx))
    else:
        return -1


assert solution([4, 1, 3, 5, 6], 0) == 3
assert solution([4, 1, 3, 5, 6], 4) == -1
assert solution([1, 3, 5, 2, 4], 0) == 3