rahul
BAN USERThe solution is to find out maximum occurring element from second position till last
For example for below input
ABC
BCD
CBA
We need create a map that will have the below
0th index - skipping it as not needed
1st index - 'B' occurs max times count = 2
2nd index - All have same no of occurrence but storing 'C' as it came first
HashMap
-------------
Key - Index
Value - <Character, Count> (although count not required if its not an online algorithm)
Steps:
1. First take all the elements falling in column 2 from (ABC,BCD,CBA) which is 'B', 'C', 'B'
2. Put them in a Hash and increment count for no of occurences and make sure you note down separately the first element you have processed, as it will be used in cases of equal occurences of elements.
3. Note down the max occurring character and count in a structure or Hashmap with key as column index and value as character.
4. Repeat the above steps for all columns.
Now as the user inputs suggest him the next word.
Assume we are interested in only searching file names not folder names.
- rahul January 12, 2014-Form a Suffix tree for all the file names. This will enable to search file name containing 'Amazon' and can work for any names. And also with this approach search is faster and adding new file entry is also simple
If the interviewer is also interested in knowing the folder having the file, then this can be handled using a separate data structure which contains the list of folder paths alone and tag them with unique id. Use this id in suffix tree leaf node, to indicate the folder they belong to.