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 treeQuestion You are given n tasks, each taking a certain number of hours to complete. Tasks may depend on other tasks - a task cannot start until...
start to stock end. If there is no path, return -1.def find_shortest_path(graph: Dict[str, Dict[str, int]], start: str, end: str) -> Union[int, List[str]]:graph = {'A': {'B': 5, 'C': 10}, 'B': {'C': 3, 'D': 1}, 'C': {'D': 2}, 'D': {}}[A, B, C, D] A to D is A -> B -> C -> D with a total cost of 5 + 3 + 2 = 10.graph = {'A': {'B': 2}, 'B': {'C': 2}, 'C': {'A': 1}}-1 A to C in this circular transaction graph.min_transaction_cost that takes in the following parameters:stock_count: int: Number of stocks (nodes in the graph)edges: List[Tuple[int, int, int]]: A list of tuples, where each tuple represents a directed edge in the form (source, destination, cost).start: int: Starting stock.end: int: Target stock.start to end. If no path exists, return -1.def min_transaction_cost(stock_count: int, edges: List[Tuple[int, int, int]], start: int, end: int) -> int:stock_count = 5, edges = [(0, 1, 100), (1, 2, 100), (1, 3, 200), (3, 4, 100)], start = 0, end = 4 300 stock_count = 5, edges = [(0, 1, 100), (1, 2, 100), (1, 3, 200), (3, 2, 50), (2, 4, 100)], start = 0, end = 4 350 def 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