Print indices in non | 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
def printOrder ( order , N , X ) : NEW_LINE INDENT vect = [ ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT if ( order [ i ] % X == 0 ) : NEW_LINE INDENT vect . append ( [ order [ i ] // X , i + 1 ] ) NEW_LINE DEDENT else : NEW_LINE INDENT vect . append ( [ order [ i ] // X + 1 , i + 1 ] ) NEW_LINE DEDENT DEDENT vect = sorted ( vect ) NEW_LINE for i in range ( N ) : NEW_LINE INDENT print ( vect [ i ] [ 1 ] , end = " ▁ " ) NEW_LINE DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT N , X = 3 , 3 NEW_LINE order = [ 2 , 7 , 4 ] NEW_LINE printOrder ( order , N , X ) NEW_LINE DEDENT