Goldman Sachs | CoderPad 1st round | US - Software Engineer
Summary
I had a 1 hour 15 minute CoderPad interview for a Software Engineer role at Goldman Sachs, where I was asked two Data Structures & Algorithms questions.
Full Experience
It was 1:15hrs long interview, and I was asked 2 DSA questions:
1. Given a list of student and scores, return the max average of all students.
It's basically the High Five problem (easy) on leetcode, but even easier in a way, that you don't need a min heap as a key, but just a list of [total of scores, number of scores].
2. Return the ID of the tallest tree given a forest with many unconnected trees (dictionary with child -> parent). If two trees have the same height, return the ID with lesser value.
Input: {2:3, 3:5, 4:5, 8:9} -> Return 5, since it is the root of the tallest tree.
Build an adjaceny list, and also store all_nodes and children in 2 separate sets. We can get the roots by doing set subtraction (all_nodes - children). Then implement DFS, and call DFS on each root to get the tree height.
Interview Questions (2)
Max Average of All Students
Given a list of student and scores, return the max average of all students. It's basically the High Five problem (easy) on leetcode, but even easier in a way, that you don't need a min heap as a key, but just a list of [total of scores, number of scores].
Tallest Tree in a Forest
Return the ID of the tallest tree given a forest with many unconnected trees (dictionary with child -> parent). If two trees have the same height, return the ID with lesser value.
Input: {2:3, 3:5, 4:5, 8:9} -> Return 5, since it is the root of the tallest tree.