Total Rounds: 4
OA:
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 same length]. Grab the largest length as start popping out elements until I found the second largest one. Mentioned about 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. 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]