First False Value - aloalgo

First False Value

Easy

You are given an array of boolean values, values.

Your task is to find the index of the first false value in values.

You may assume that:

  • All true values in values appear before any false values.

Return the 0-based index of the first false value, or -1 if values contains no false values.

Example 1

Input
[True, True, False, False, False]
Output
2
Explanation:

The first false value is at index 2.

Example 2

Input
[True, True, True]
Output
-1
Explanation:

All values are true, so no false value is found.

Example 3

Input
[False, False, False]
Output
0
Explanation:

The first false value is at index 0.

Example 4

Input
[]
Output
-1
Explanation:

The array is empty, so no false value is found.

Loading...
Input
[True, True, False, False, False]
Output
2

Hello! I am your ✨ AI assistant. I can provide you hints, explanations, give feedback on your code, and more. Just ask me anything related to the problem you're working on!