Company: flipkart_27feb

Difficulty: medium

Problem Statement

In an online game, the player is provided with a series of strings and is expected to rearrange each string such that the new arrangement is the next possible string in the dictionary order. Write a program to help the player achieve this task. If such a rearrangement is not possible, then print "no changes" Read the input from STDIN and print the output to STDOUT. Do not print arbitrary strings anywhere in the program, as these contribute to the output and test cases will fail. Constraints: 1 < n < 10000, the number of strings in each test case. Each string contains letters in range from [a...z] only Input format: The first line of input contains n Next n lines contain a string each Output format: For each input string, the output string meets the criteria and if no possible changes are available, print "no changes". Sample Input 1: 3 dcab dd bca Sample Output 1: dcba no changes cab Explanation 1: For the first string 'dcab', rearranging the letters gives us 'dcba' which is the

More flipkart_27feb OA questionsInterview experiences