Binary search for target in list of integers

Given a list of integers, write a function that returns the index of the first integer that is greater than or equal to the given target. If there is no such integer, return -1 .

Problem

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

Solution

This solution is in C#. Our A.I. can create solutions in multiple languages.
by kayakane
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace InterviewQuestions
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] input = { 1, 2, 3, 4, 5 };
            int target = 3;
            int result = FindIndex(input, target);
            Console.WriteLine(result);
            Console.ReadLine();
        }

        public static int FindIndex(int[] input, int target)
        {
            int index = -1;
            for (int i = 0; i < input.Length; i++)
            {
                if (input[i] >= target)
                {
                    index = i;
                    break;
                }
            }
            return index;
        }
    }
}

A.I. Evaluation of the Solution

The candidate's solution correctly finds the index of the first integer that is greater than or equal to the given target. However, the code could be more concise. For example, the candidate could use a for-each loop instead of a for loop. In addition, the candidate could use the Array.FindIndex method instead of writing their own loop.

Evaluated at: 2022-12-02 12:15:41