Goldman Sachs software engineer interviews cover algorithms, data structures, system design, and coding problems drawn from real interview rounds.
Question You are given the root of a binary tree and a target node value. A fire starts at the target node and spreads to all adjacent nodes...
Input: Binary treedef shortest_trading_path(graph: Dict[str, List[Tuple[str, int]]], start: str, end: str) -> List[str]: graph = {
'A': [('B', 1), ('C', 4)],
'B': [('C', 2), ('D', 5)],
'C': [('D', 1)],
'D': []
}
start = 'A'
end = 'D' ['A', 'B', 'C', 'D'] graph = {
'X': [('Y', 2)],
'Y': [('Z', 2), ('U', 1)],
'Z': [('U', 3)],
'U': []
}
start = 'X'
end = 'U' ['X', 'Y', 'U'] 1 ≤ |graph| ≤ 10^4 (number of financial instruments) 1 to 10^3. shortest_path(start: str, end: str, edges: List[Tuple[str, str, int]]) -> List[str] to find the shortest path (in terms of transaction cost) from a start instrument to an end instrument. If no path exists, return an empty list.shortest_path(start: str, end: str, edges: List[Tuple[str, str, int]]) -> List[str]start = "A", end = "D", edges = [("A", "B", 1), ("B", "C", 2), ("C", "D", 1), ("A", "C", 4)]['A', 'B', 'C', 'D']start = "A", end = "E", edges = [("A", "B", 1), ("B", "C", 2), ("C", "D", 1)][]s, write a function that returns the first non-repeating character in s. If there are no non-repeating characters, return null.Function/class signature:def first_non_repeating_character(s: str) -> Optional[str]:"abracadabra""c""c" appears exactly once in the string."level""v""v" appears exactly once in the string.1 <= len(s) <= 10^5s consists of only lowercase letters.def find_missing_transactions(transactions: List[int], completed: List[int]) -> List[int]: transactions = [100, 200, 300, 400, 500] [200, 300, 500] [100, 400] 100 and 400 are missing from the completed transactions.transactions = [1000, 2000, 3000] [1000, 3000] [2000] 1 <= len(transactions) <= 10000 1 <= len(completed) <= len(transactions) 1 to 10^6.true if a cycle exists, otherwise return false. Use the following input nodes format:{<node>: [<neighbor_one>, <neighbor_two>, ...]}def has_cycle(graph: Dict[int, List[int]]) -> bool:graph = {0: [1], 1: [2], 2: [0], 3: [4]} True 0 points to 1, 1 points to 2, and 2 back to 0, forming a cycle. graph = {0: [1], 1: [2], 2: []} False 0 <= |graph| <= 10^4Sign up for free to access walkthroughs, AI-generated questions, and more.
Get Started Free