395. String Sorting Challenge
Nishant, a mischievous student in the Launchpad Batch, has jumbled up a set of strings. Your task is to assist Nishant in sorting the strings lexicographically. However, if one string is a complete prefix of another string, the longer string should be placed before the shorter one in the sorted order. For example, if we have the strings 'bat' and 'batman', where 'bat' is a prefix of 'batman', the sorted order should be 'batman' followed by 'bat'.
The input consists of an integer N followed by N strings.
The output should consist of N lines, each containing one string.
3 bat apple batman
apple batman bat