Driver code
public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 2 , 3 , 4 , 4 , 5 , 6 } ; int n = arr . length ; ArrayList < List < Integer > > Q = new ArrayList < > ( ) ; Q . add ( Arrays . asList ( 1 , 3 , 5 ) ) ; Q . add ( Arrays . asList ( 1 , 2 , 4 ) ) ; Q . add ( Arrays . asList ( 1 , 1 , 2 ) ) ; Q . add ( Arrays . asList ( 2 , 1 , 7 ) ) ; Q . add ( Arrays . asList ( 1 , 1 , 2 ) ) ; SolveQuery ( arr , n , Q ) ; } }