Category
Returns the first index of the last continuous group of a given value. Strict equality (===) is used to compare elements.
===
Time complexity: O(n)
Space complexity: O(1)
The array to search
The value to search for
The first index of the last group of a given value
const array = ['a', 'a', 'b', 'b', 'c', 'c'];firstIndexOfLastGroup(array, 'c'); // 4 Copy
const array = ['a', 'a', 'b', 'b', 'c', 'c'];firstIndexOfLastGroup(array, 'c'); // 4
lastIndexOfFirstGroup to do the same thing but find the last index of the first group
Array
Returns the first index of the last continuous group of a given value. Strict equality (
===
) is used to compare elements.Time complexity: O(n)
Space complexity: O(1)