Print indices in non | package whatever do not write package name here ; Function to print the order of array elements generating non - decreasing quotient after division by X ; Stores the quotient and the order ; Traverse the array ; Sort the vector ; Print the order ; Driver Code
import java . io . * ; import java . util . * ; class GFG { static void printOrder ( int order [ ] , int N , int X ) { ArrayList < int [ ] > vect = new ArrayList < > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { if ( order [ i ] % X == 0 ) { vect . add ( new int [ ] { order [ i ] / X , i + 1 } ) ; } else { vect . add ( new int [ ] { order [ i ] / X + 1 , i + 1 } ) ; } } Collections . sort ( vect , ( a , b ) -> a [ 0 ] - b [ 0 ] ) ; for ( int i = 0 ; i < N ; i ++ ) { System . out . print ( vect . get ( i ) [ 1 ] + " ▁ " ) ; } System . out . println ( ) ; } public static void main ( String args [ ] ) { int N = 3 , X = 3 ; int order [ ] = { 2 , 7 , 4 } ; printOrder ( order , N , X ) ; } }