Heres what i did:
- find if all similar names are lexo sorted (i.e. those having least one char i.e. first one same (will be grouped together)), if so…
probably rearranging alphabets, a solution would be possible…
- print alphas starting from ‘a’…‘z’ till first elements first char (which don’t appear in any names)
- print all names first char (avoid repetition), as all similar will be grouped and are lexo-sorted as above checked else would have been impossible.
- print the rest one’s (alphabets) that didn’t appear in list.
Though i tried looking at someone else code and test cases, i got the code but where can a loop occur or why do i need a dfs, if anyone could give me an example i.e. test case i will be thankful to him/her. Thanks in advance. tried it but " failed at 12th test case " , feel free to point out my mistake in
Like in first example,… print all alphabets from ‘a’ to till ‘r’ i.e. first alphabet of first name, excluding those that appear somewhere as first alphabet in any name, i.e. form ‘b’ to till ‘q’ and then all names first alphabets then again starting from ‘r’ to till ‘z’ that haven’t been printed, so solution becomes
alpha + names alpha + remaining alphas =
“bcdef…q” + “rsa” +“tuvwxyz” = bcde…q rqsa tuv…zProbably logic is wrong, but couldn’t find the need of dfs in the question. PLEASE HELP!!!