Oracle (OCI) | Phone | Sort Array by Increasing Frequency
Anonymous User
1228

Yesterday I had my OCI technical phone round. Interviewer started with his introduction followed by my introduction. Then I was asked a standard behavioural question - Tell me about a time when you had a conflict with your team member.

After that I was given a LC easy problem.

Problem: You are given an array of n integers, sort the array in ascending order first by their frequency then by their value.
Similar LC Problem: Sort Array by Increasing Frequency
Sample Input: [3, 4, 5, 6, 4, 3]
Sample Output: [5, 6, 3, 3, 4, 4]
Solution:

  1. Used a hash map to store frequency of each interger.
  2. Made an array of pair of each interger their value and frequency.
  3. Sort the array first based on their frequency and then based on their value.
  4. Go through the array of pairs and build the result array.
  5. Return the result

We used hackerrarnk platform for coding. After coding we went through the code tegether and gave a dry run on the sample test case. I used hash map in the problem and interviewer also asked how the hash map works and the time complexity of my code.

Then we had a discussion on the following problem - Suppose we have an api to put list of names in the DB. It's only responsibility is to put data in DB. Once the DB starts to grow it starts to have higher latency. How'd you proceed to find the problem in the system.

In the end I was given another problem, a simplified version of Valid Parenthese, we assumed only '(' or ')' is allowed. I didn't have to code this, just had to explain the solution in words.

After that I asked a few question about OCI and his team. Then we concluded the interview. Interviewer was very nice and friendly.

Comments (2)