Skip to content

Instantly share code, notes, and snippets.

@catchmrbharath
Last active December 16, 2015 15:08
Show Gist options
  • Select an option

  • Save catchmrbharath/5453299 to your computer and use it in GitHub Desktop.

Select an option

Save catchmrbharath/5453299 to your computer and use it in GitHub Desktop.

Description

You are given N strings and you have to sort the strings according to the following rules.

  • S1 < S2 if S1 has fewer vowels than S2.
  • If the number of vowels are equal then, S1 < S2 if S1 has fewer number of words.
  • If both the above are tied, then the string with the longest word is greater.
  • else the strings are equal.

The number of words in the string does not exceed 10. Each word does not have more than 10 letters. You need to output the sorted set of strings. N <= 100000.

The sorting has to be stable

Sample input

aa
bda dks
cabd ekdls lmnk

Sample Output

bda dks
aa
cabd ekdls lmnk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment