C ++ program to find index of first occurrence of x when array is sorted .
#include <bits/stdc++.h> NEW_LINE using namespace std ; int findFirst ( int arr [ ] , int n , int x ) { sort ( arr , arr + n ) ;