First Number Larger Than Target in List

Given a list of integers and a target number, the function should return the index of the first number in the list that is larger than the target number. If there is no such number, the function should return -1.

Problem

Given a list of integers, write a function that returns the index of the first number that is larger than the given target number. If there is no such number, return -1.
Example input: 
[1, 2, 3, 4, 5], target = 3
Example output: 
2

Solution

This solution is in Python. Our A.I. can create solutions in multiple languages.
by kayakane
def find_first_larger(lst, target):
    for i in range(len(lst)):
        if lst[i] > target:
            return i
    return -1

# This solution is optimal because it is O(n) time complexity.
# It is also optimal because it is O(1) space complexity.

A.I. Evaluation of the Solution

This solution is correct and demonstrates a good understanding of time and space complexity.

Evaluated at: 2022-11-11 00:15:55