Goldman Sachs | Phone | Highest Average Score & Power of 10

Anonymous User
34344
Oct 01, 2019
Mar 07, 2020

Date: Sep 2019

I got a phone screen for SDE position in Commercial Banking division.
The interview was for one hour and I was supposed to solve 2 questions. Unfortunately, I took a lot of time to solve my first question itself so, I naturally flustered and panicked while solving the second with 5 miutes of time remaining.

Question 1:
Given a 2-D String array of student-marks find the student with the highest average and output his average score. If the average is in decimals, floor it down to the nearest integer.

Example 1:

Input:  [{"Bob","87"}, {"Mike", "35"},{"Bob", "52"}, {"Jason","35"}, {"Mike", "55"}, {"Jessica", "99"}]
Output: 99
Explanation: Since Jessica's average is greater than Bob's, Mike's and Jason's average.

Follow-up:
Questions: What is the time complexity? What is the space complexity? Can you solve it in O(n) time? (I used an integer array to store the average and sorted it using Arrays.sort(). But then, I refined my code to store only the maximum average, when I calculated the average).

The interviewer was insistant on me testing for more cases. She also helped me point out where my code was going wrong (I was trying to add integers but my code was concatenating and then converting to Integer) and I quickly fixed it.

There was like 5 minutes remaining, so she gave me a relatively simpler one. Of course, the idiot that I am, I had to mess up even the simplest of the questions.

Question 2:
https://leetcode.com/problems/power-of-three/
Given an integer, find out whether it is a power of 10 or not.

In panic mode, I misunderstood power as multiple, then quickly realized my foolishness. Then I told the interviewer of my approach, the time complexity and space complexity.

Comments (53)