Snapchat software engineer interviews cover algorithms, data structures, system design, and coding problems drawn from real interview rounds.
m x n binary grid where each cell is either '1' (land) or '0' (water). A group of connected land cells (connected horizontally...Input: 2D grid[A, B] means task A must complete before task B can start....Input: Graph (nodes and edges)m x n binary grid where '1' is land and '0' is water. For each island (a connected group of land cells using horizontal and...Input: 2D gridn people labeled 0 to n - 1, friendship is mutual and transitive through direct connections. People belong to the same...Input: Lists. The expression may contain positive and negative integers, the...Input: Stringprimes where every element is a prime number (duplicates are allowed), find all distinct products that can be formed by multiplying...Input: Array[entry, exit), meaning they are present at every integer...Input: List[id, manager_id, name]. The CEO is the only employee whose manager_id equals...Input: List. for an ordinary walkable cell, # for a barrier, or R for a restaurant. Starting at start, you may move one cell up, down, left, or right. Every move costs one unit of walking distance.A route may enter at most budget barrier cells. Each move into a # cell consumes one unit of that route's budget, including repeated entries into the same barrier. Moving out of a barrier into a non-barrier cell consumes no budget. The budget applies independently to each candidate route: you are finding nearby destinations, not planning one trip that visits every restaurant.Return up to k reachable restaurants as records with integer fields row, col, and distance. A restaurant's distance is the minimum number of moves among all routes that respect the budget. Return each restaurant only once, ordered by distance ascending, then row ascending, then column ascending. If the starting cell is a restaurant, its distance is zero. Restaurants may be traversed like ordinary walkable cells.Your implementation must avoid enumerating individual routes. In particular, explain why marking a grid coordinate as visited without considering the remaining crossing budget can produce an incorrect answer.Function or class signaturenearest_restaurants(grid: list[str], start: tuple[int, int], k: int, budget: int) -> list[dict[str, int]]{"grid":[".R#R.",".###.","R...R"],"start":[0,0],"k":3,"budget":1}Output:[{"row":0,"col":1,"distance":1},{"row":2,"col":0,"distance":2},{"row":0,"col":3,"distance":3}]Explanation: The first two restaurants require no barrier crossings. The route (0,0) → (0,1) → (0,2) → (0,3) reaches the third restaurant in three moves and enters one barrier. The restaurant at (2,4) is reachable in six moves but is outside the nearest three.Example 2:Input:{"grid":["R#R","###","R.R"],"start":[0,0],"k":5,"budget":0}Output:[{"row":0,"col":0,"distance":0}]Explanation: The starting restaurant is included. Both adjacent cells are barriers, so no other restaurant is reachable without crossing a barrier.Constraints:1 <= rows, cols <= 200 and rows * cols <= 40000.., #, or R.start is an in-bounds coordinate containing . or R.0 <= budget <= 30.0 <= k <= rows * cols; return an empty list when k == 0.-1. Implement a function using binary search to optimize the search efficiency.def find_username(usernames: List[str], target: str) -> intusernames = ['alice', 'bob', 'charlie', 'dave'], target = 'charlie' 2 usernames = ['alice', 'bob', 'charlie', 'dave'], target = 'eve' -1 1 <= len(usernames) <= 10^4 username has at most 100 characters, containing only lowercase letters and numbers."unknown".def check_user_status(user_ids: List[str], user_status: Dict[str, str]) -> List[str]:user_ids = ["user1", "user2", "user3"], user_status = {"user1": "active", "user2": "inactive"} ['active', 'inactive', 'unknown'] user1 is active, user2 is inactive, and user3 has no status set.user_ids = ["user3", "user4"], user_status = {"user4": "active"} ['unknown', 'active'] user3 is not in the mapping, while user4 is active.1 <= len(user_ids) <= 10^41 <= len(user_status) <= 10^4def suggest_friends(user: str, connections: List[Tuple[str, str]]) -> List[str]: user = "Alice", connections = [("Alice", "Bob"), ("Alice", "Charlie"), ("Bob", "David"), ("Charlie", "David"), ("Bob", "Eve")] ['David', 'Eve'] user = "Bob", connections = [("Alice", "Bob"), ("Alice", "Charlie"), ("Bob", "David"), ("Charlie", "David"), ("Bob", "Eve")] ['Charlie', 'Eve'] (a, b) implies both a is a friend of b and vice versa.def max_snap_filters(filters: List[int], preferences: List[Tuple[int, int]]) -> int:filters = [1, 3, 5, 7], preferences = [(2, 5), (3, 7)]3filters = [2, 4, 6], preferences = [(1, 3), (4, 5)]11 <= len(filters) <= 1000001 <= len(preferences) <= 100000 <= filters[i] <= 1000 <= preferences[i][0] <= preferences[i][1] <= 100k steps.def find_users_in_group(graph: Dict[int, List[int]], start_user: int, k: int) -> List[int]:graph = {1: [2, 3], 2: [1, 4], 3: [1], 4: [2]}, start_user = 1, k = 2 [1, 2, 3, 4] 1, within 2 steps, all users 2, 3, and 4 are reachable.Example 2: graph = {1: [2], 2: [1, 3], 3: [2], 4: []}, start_user = 2, k = 1 [2, 1, 3] 2, within 1 step, users 1 and 3 are reachable.Constraints: 10^5 users. 0 <= k <= 10^5. s, your goal is to find the length of the longest substring that does not contain any repeated characters. This challenge is critical for Snapchat as it could relate to efficiently managing and displaying unique identifiers in user-generated content across the platform.def longest_unique_substring(s: str) -> int:"abcabcbb" 3 "abc", which has length 3."bbbbb" 1 "b", which has length 1.s.length <= 1000s consists of English letters, digits, symbols, and spaces.Sign up for free to access walkthroughs, AI-generated questions, and more.
Get Started Free