Skip to main content

Interview Experience in a search based tech start up



once  i had an interview with a tech startup;  there were few programming problems; i am sharing one from that interview.

Interview Location :Bangalore
Company: A product based start up that works on search and big data.
Round : 2nd
Level: semi difficult
Program & Algo written on: white board
Problem statement:  
Given an array like
A
B
C
A
A
Z
K
I
A
Z
Sort  the array based on frequency of character, if frequency is same sort them based on ASCII.
{a=4,b=1,c=1,z=2,k=1,i=1}
Out put :

A
A
A
A
Z
Z
B
C
I
K

What i did  during that interview i am writing here:

Algo To solve the problem:
      
      1. Find their frequency  using hashtable.
      2.  Prepare a class with {data : frequency } and put them in a list.
      3. Sort  list using  Collections.sort(); to do that we should  implement comparable interface.
      now prepare an array  using sorted list so that it gives desired output like "AAAAZZBCIK"

 click on the below link:


Next  was a brainstorming  session with lead of the product division to optimize the above program.

Note:

I am  prone to  typo; please report them and I will try to update the posts accordingly.




Comments