LC: 1426. Counting Elements - spiralgo/algorithms GitHub Wiki

1426. Counting Elements:

The Essence:

The aim of this question teaching us how to search in an integer array. Pay attention to that the array is not sorted.

Details:

The Binary Search algorithm is a good candidate to solve the problem. But we need to sort the array first. We will iterate over the array and search for x+1 in the same array for each x element in the array.