Total Rounds: 4
OA:
- [Medium] leetcode.com/problems/least-number-of-uniqu..
- [Easy] Basic Sorting on the basis of Parameters.
Round-1:
Find the second largest number from an array of numbers represented as strings. For Ex- input = ["21", "32", "432", "435", "9982", "324", "1", "98", "435"] Output = "435" Constraints = A number can have 2^10 (1024) digits.
Approach Taken
Let us store the elements in a hashmap of
[key, values]
as[length of string, a max-heap containing the elements of the same length]
. Grab the largest length as start popping out elements until I found the second largest one. Mentioned the edge cases that may arise here.i. There might be multiple instances of numbers of the highest length. ii. Input consisting of just 1 or no element.
Time Complexity: O(n)
Got panicked and couldn't write the working code. The interviewer was running out of time and told me if I could complete it. I finally told him I can write the brute force sort solution for this. Wrote the brute force code.
- Told the interviewer about Kadane's Algorithm and implemented it.
[REJECTED]