Apple backend engineer interviews typically focus on APIs, databases, system design, concurrency, caching, and data structures.
No verified questions yet for Apple.
k, return the maximum number of active connections at any given time within the last k seconds.- def max_active_connections(times: List[int], k: int) -> int: returns the maximum number of connections.Example 1:times = [1, 2, 5, 6, 7], k = 335, there are 3 active connections (from 3 to 5).Example 2:times = [1, 2, 3, 4, 5], k = 224 and 5, the number of active connections within k=2 seconds is 2.Constraints:1 <= len(times) <= 10^51 <= k <= 10^3def dijkstra(graph: Dict[int, List[Tuple[int, int]]], source: int) -> Dict[int, int]: returns a dictionary mapping each node to its shortest distance from the source.Example 1:graph = {0: [(1, 4), (2, 1)], 1: [(3, 1)], 2: [(1, 2), (3, 5)], 3: []}, source = 0{0: 0, 1: 3, 2: 1, 3: 4}0 to all other nodes are calculated.Example 2:graph = {0: [(1, 2)], 1: [(2, 5)], 2: []}, source = 0{0: 0, 1: 2, 2: 7}0.Constraints:1 <= len(graph) <= 10^50 <= source < len(graph)Sign up for free to access walkthroughs, AI-generated questions, and more.
Get Started Free