Round 1
Questions:
Question
Given an array of sorted integers, sort the array in ascending order of squares of its elements.
For example:
[1, 5, 7, 7, 8, 10] -> [1, 5, 7, 7, 8, 10] [-5, -3, -3, 2, 4, 4, 8] -> [2, -3, -3, 4, 4, -5, 8]
i.e., squares : [4, 9, 9, 16, 16, 25, 64]
Follow-up Question
- Find kth min or max element after sorting. The interviewer was looking for O(LogN) time complexity for this follow-up question which I could not achieve.
Candidate's Approach
No approach provided.
Interviewer's Feedback
No feedback provided.
Round 2
Questions:
Question
Given a series of text, write some code to find the top k terms in that text.
Text: b a b a a c
k: 2
Result: ["a", "b"]
since a occurs 3 times, b 2 times.
Follow-up Question
- What if we have to split the text on different characters?
Candidate's Approach
No approach provided.
Interviewer's Feedback
No feedback provided.