http://www.geeksforgeeks.org/elements-no-element-bigger-array/
Given an array of integers, the task is to find count of elements before which all the elements are smaller. First element is always counted as there is no other element before it.
int
countElements(
int
arr[],
int
n)
{
// First element will always be considered as greater
// than previous ones
int
result = 1;
// Store the arr[0] as maximum
int
max_ele = arr[0];
// Traverse array starting from second element
for
(
int
i=1; i<n; i++)
{
// Compare current element with the maximum
// value if it is true otherwise continue
if
(arr[i] > max_ele)
{
// Update the maximum value
max_ele = arr[i];
// Increment the result
result++;
}
}
return
result;
}