高盛店面

面的是 SDE 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 minutes of time remaining.

Coding 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.
eg Input: [{“Bob”,“87”}, {“Mike”, “35”},{“Bob”, “52”}, {“Jason”,“35”}, {“Mike”, “55”}, {“Jessica”, “99”}]
Output: 99 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.

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

我在 Codepad.io 做的,考了两题

  1. Find the first non repeating character in a string.
    Eg: apple --> a
    appletatr --> e
    return -1 if none found.

  2. Find the smallest subarray length with target more than or equal to the sum of the subarray. The numbers are non sorted. Return -1 if not possible.
    eg: {1,2,3,4}
    sum 6 --> 2
    sum 12 --> -1