Java program previous greater element An efficient solution to print previous greater element for every element in an array .
import java . io . * ; import java . util . * ; import java . lang . * ; class GFG { static void prevGreater ( int arr [ ] , int n ) {