Java program of the above approach
import java . io . * ; import java . util . * ; public class Pair { private final int key ; private final int value ; public Pair ( int aKey , int aValue ) { key = aKey ; value = aValue ; } public int key ( ) { return key ; } public int value ( ) { return value ; } } class GFG { static int [ ] arr = new int [ 10005 ] ;