Given a boolean array arr that is partitioned into a prefix of false values followed by a suffix of true values, return the index of the first true. If no true exists, return -1.
Input
arr: array of booleans, all false values precede all true values
Output
The smallest index where arr[i] is true, or -1 if every value is false.
Examples
Example 1
Inputarr = [false, false, true, true, true]
Output2
Example 2
Inputarr = [false, false, false]
Output-1
Constraints
0 <= arr.length <= 10^5
The array, if non-empty, has the form [false, ..., false, true, ..., true].