Google Interview Question for Software Developers
- 11of 11 votes
Given a string which only contains lowercase. You need delete the repeated letters only leave one, and try to make the lexicographical order of new string is smallest.- lxfuhuo September 09, 2015 in -
You need delete 1 'b' and 1 'c', so you delete the first 'b' and first 'c', the new string will be abc which is smallest.
ps: If you try to use greedy algorithm to solve this problem, you must sure that you could pass this case:
cbacdcbc. answer is acdb not adcb
I can't solve this problem well and the interviewer said that you can scan the string twice. First scan is do some preprocess, and the second is to get the answer, but I really can't come up this idea.
| Report Duplicate | Flag | PURGE
Google Software Developer Algorithm
Interview Type: Phone Interview
Open Chat in New Window