Coinbase software engineer interviews cover algorithms, data structures, system design, and coding problems drawn from real interview rounds.
Question You are designing an NFT generation engine. You are given a set of Traits, where each trait has a name and a list of possible...
Input: ListQuestion You are building a block construction module for a blockchain node. The goal is to select a subset of pending transactions to include in...
Input: Graph (nodes and edges)Question Design a crypto trading system that manages a stream of orders. The system should support various operations like placing, pausing,...
Input: Array of stringsQuestion For this problem, you will be designing a series of different iterator classes. This problem is split into multiple related parts that...
Input: Array of integersQuestion For this problem, you will be designing a food delivery system. This problem is split into three related parts, evolving from basic data...
Input: ListQuestion Your task is to implement a simple in-memory cloud storage system that maps objects (files) to their metadata (name, size, etc.). You...
Input: Graph (nodes and edges)Question Design a banking system that supports account management, transactions, and various financial operations.
Input: Graph (nodes and edges)KnowledgeBaseSystem that stores articles with CRUD operations. The system operates entirely...Input: Graph (nodes and edges)startNode to a destination wallet endNode. Each edge is equivalent to a transaction that can either be successful or failed. If no such path exists, return None.Function/class signature: def shortest_path(graph: Dict[str, List[str]], startNode: str, endNode: str) -> Optional[List[str]]:graph = { 'A': ['B', 'C'], 'B': ['D'], 'C': ['D'], 'D': [] } startNode = 'A' endNode = 'D' ['A', 'B', 'D'] graph = { 'A': ['B', 'C'], 'B': [], 'C': ['D'], 'D': [] } startNode = 'A' endNode = 'D' None TransactionFilter class that filters a list of transactions based on specific criteria. Each transaction is represented as a dictionary containing amount, currency, timestamp, and status. The class should have a method filter_transactions(transactions: List[Dict[str, Union[str, float]]], min_amount: float, currency_filter: str) -> List[Dict[str, Union[str, float]]] that returns all transactions where the amount is greater than or equal to min_amount and matches the given currency_filter. Function/class signature:class TransactionFilter: def filter_transactions(transactions: List[Dict[str, Union[str, float]]], min_amount: float, currency_filter: str) -> List[Dict[str, Union[str, float]]]: transactions = [{'amount': 100.0, 'currency': 'USD', 'timestamp': '2023-10-01', 'status': 'completed'}, {'amount': 50.5, 'currency': 'EUR', 'timestamp': '2023-10-02', 'status': 'pending'}, {'amount': 150.0, 'currency': 'USD', 'timestamp': '2023-10-03', 'status': 'completed'}], min_amount = 100.0, currency_filter = 'USD' [{'amount': 100.0, 'currency': 'USD', 'timestamp': '2023-10-01', 'status': 'completed'}, {'amount': 150.0, 'currency': 'USD', 'timestamp': '2023-10-03', 'status': 'completed'}] min_amount of 100.0 and are in USD. transactions = [{'amount': 200.0, 'currency': 'USD', 'timestamp': '2023-09-01', 'status': 'completed'}, {'amount': 60.0, 'currency': 'EUR', 'timestamp': '2023-09-02', 'status': 'failed'}, {'amount': 150.0, 'currency': 'EUR', 'timestamp': '2023-09-03', 'status': 'completed'}], min_amount = 70.0, currency_filter = 'EUR' [{'amount': 150.0, 'currency': 'EUR', 'timestamp': '2023-09-03', 'status': 'completed'}] EUR. def max_profit(prices: List[int]) -> int:[7, 1, 5, 3, 6, 4]5[7, 6, 4, 3, 1]01 <= prices.length <= 10^5 0 <= prices[i] <= 10^4n + 1 integers where each integer is in the range [1, n], write a function to find the duplicate number. You must solve it without modifying the array and using O(1) extra space. Your solution should have a time complexity better than O(n^2).def find_duplicate(nums: List[int]) -> int:[3, 1, 3, 4, 2]33 appears twice.[1, 2, 3, 4, 4]44 appears twice.2 <= n <= 10^5[1, n] and there is at least one duplicate.src to a destination transaction dest. The graph is given as an adjacency list, and each edge has a non-negative cost.Function/class signature:def shortest_path(graph: Dict[str, List[Tuple[str, int]]], src: str, dest: str) -> Tuple[List[str], int]:graph = {"A": [("B", 1), ("C", 4)], "B": [("C", 2), ("D", 5)], "C": [("D", 1)], "D": []} src = "A", dest = "D" graph = {"X": [("Y", 2)], "Y": [("Z", 3)], "Z": []} src = "X", dest = "Z" 1 <= len(graph) <= 1000 0 <= cost <= 1000 n + 1 integers where each integer is in the range [1, n], find the duplicate number. You must solve it without modifying the array and using O(1) extra space. The solution should be optimized to have a better time complexity than O(n^2).def find_duplicate(nums: List[int]) -> int:[3, 1, 3, 4, 2] 3 3 is repeated in the array.[1, 3, 4, 2, 2] 2 2 is repeated in the array.1 <= n <= 10^5 [1, n] and there's guaranteed to be one duplicate.flights with columns flight_id, departure_airport, arrival_airport, and departure_time, you are required to return the flight_ids that have more than one layover. A layover is defined as having multiple connections in the journey from the departure to the final arrival airport. You should calculate the number of layovers by comparing the departure and arrival times of consecutive flights. def find_flights_with_layovers(flights: List[Tuple[int, str, str, str]]) -> List[int]:flights = [(1, 'A', 'B', '2023-01-02 08:00'), (2, 'B', 'C', '2023-01-02 10:00'), (3, 'C', 'D', '2023-01-02 12:00'), (4, 'A', 'D', '2023-01-02 09:00')]
Output: [1]
Explanation: Flight 1 has two layovers via B and C to reach D.
Example 2:
Input: flights = [(5, 'X', 'Y', '2023-01-03 07:00'), (6, 'Y', 'Z', '2023-01-03 09:00'), (7, 'Y', 'X', '2023-01-03 10:30')] [] departure_airport and arrival_airport are strings representing airport codes.d days window, compute the total number of distinct markets open during that window.def count_active_markets(timestamps: List[Tuple[int, int]], d: int) -> int: returns an integer count of active markets.timestamps = [(1, 5), (2, 3), (4, 6)], d = 3 2 timestamps = [(1, 2), (3, 5), (7, 10)], d = 3 1 1 to 4.Constraints: 1 <= timestamps.length <= 1000 1 <= d <= 10000 source user to the destination user. Users can have multiple transactions but there is a constraint on transaction types that can be traversed.def shortest_path(transactions: List[Tuple[int, int]], source: int, destination: int) -> List[int]: returns a list of users representing the shortest path.transactions = [(1, 2), (2, 3), (2, 4), (3, 4)] [1, 2, 3] transactions = [(1, 2), (1, 3), (3, 4), (2, 4)] [1, 3, 4] 1 <= transactions.length <= 100 1 <= source, destination <= 10^4 follow(follower_id: int, followee_id: int), unfollow(follower_id: int, followee_id: int), and get_feed(user_id: int) -> List[int]. The feed should return the most recent 10 transactions from the followed users.def follow(follower_id: int, followee_id: int) -> None: update the following relationship.def unfollow(follower_id: int, followee_id: int) -> None: remove the following relationship.def get_feed(user_id: int) -> List[int]: return the user feed containing transaction IDs of the most recent 10 transactions from followed users.manager = FeedManager() manager.follow(1, 2) manager.follow(1, 3) manager.get_feed(1) [x, y, z] 1 <= follower_id, followee_id <= 10^4 10^5.get(key: int) -> int and put(key: int, value: int) -> void methods.def get(key: int) -> int: returns the value of the key if it exists or -1.def put(key: int, value: int) -> None: updates the value if the key exists, otherwise, adds the key-value pair to the cache. If the cache reaches its capacity, it should invalidate the least recently used item before inserting a new item.cache = LRUCache(2) cache.put(1, 1) cache.put(2, 2) cache.get(1) 1 cache.put(3, 3) cache.get(2) -1 1 <= capacity <= 3000 0 <= key, value <= 10^4.Sign up for free to access walkthroughs, AI-generated questions, and more.
Get Started Free