Bloomberg | Sr. Software Engineer | NYC | Apr 2020 [Reject]
Anonymous User
1782

Phone interview 1:

  • https://leetcode.com/problems/design-underground-system/ While preparing, I thought it was design question and didn't expect in phone screening and didn't solve :)
    I was discussing with interviewer and implemented using two hashmaps, surprisingly lc solution also similar to what I wrote. I created separate classes, but lc solution used pairs. Infact I liked lc solution than I wrote. I was not familiar with Pair.
My code
class UndergroundSystem {
    private final Map<Integer, PassengerEntranceInfo> passengerCommuteInfo;
    private final Map<String, StationsAvgTimeInfo> averageTravelTime;

    public UndergroundSystem() {
        passengerCommuteInfo = new HashMap();
        averageTravelTime = new HashMap();
    }
    
    public void checkIn(int id, String stationName, int t) {
        passengerCommuteInfo.put(id, new PassengerEntranceInfo(stationName, t));
    }
    
    public void checkOut(int id, String stationName, int t) {
        PassengerEntranceInfo passengerEntranceInfo = passengerCommuteInfo.get(id);
        int startingTime = passengerEntranceInfo.getTime();
        String startingStation = passengerEntranceInfo.getStation();
        if(averageTravelTime.containsKey(startingStation+"-"+stationName)){
            StationsAvgTimeInfo stationsAvgTimeInfo = averageTravelTime.get(startingStation+"-"+stationName);
            int totalPassengers = stationsAvgTimeInfo.getTotalPassengers();
            double totalTime = stationsAvgTimeInfo.getAvgTime() * totalPassengers;
            totalTime += t-startingTime;
            averageTravelTime.put(startingStation+"-"+stationName, new StationsAvgTimeInfo(totalPassengers+1,totalTime/(totalPassengers+1)));
        } else {
            averageTravelTime.put(startingStation+"-"+stationName, new StationsAvgTimeInfo(1, t-startingTime));
        }
    }
    
    public double getAverageTime(String startStation, String endStation) {
        return averageTravelTime.get(startStation+"-"+endStation).getAvgTime();
    }
    
    private static class PassengerEntranceInfo {
        private final String station;
        private final int time;
        
        PassengerEntranceInfo(final String station, final int time) {
            this.station = station;
            this.time = time;
        }
        
        String getStation() {
            return station;
        }
        
        int getTime() {
            return time;
        }
    }
    
    private static class StationsAvgTimeInfo {
        private final int totalPassengers;
        private final double averageTime;
        
        StationsAvgTimeInfo(final int totalPassengers, final double averageTime) {
            this.totalPassengers = totalPassengers;
            this.averageTime = averageTime;
        }
        
        int getTotalPassengers() {
            return totalPassengers;
        }
        
        double getAvgTime() {
            return averageTime;
        }
    }
}

Phone interview 2:


Onsite
two interviews

  1. implement snake game design question, I did okay but not great
  2. implement registration system for an employee event. It was good.
    as an employee you can bring one or more number of guests, there is a limit to number of guests, and you have to allot slots to employees after registration period is over.

First question was okay, but not great. I don't think I will get offer.
Only two rounds.

Comments (6)