Category: Array coding problem# Question Given a string where letters are sorted in alphabetical order, identify all letters that appear more than twice and record their first and...Input: Array Output: Computed result
codingMediumVerified Question#2
2. GPS Error Tracking
Category: Algorithm coding problem# Question You are tracking GPS location errors by comparing measured GPS locations against a set of "golden" (reference) locations. Each location...Input: List Output: Computed result
codingHardVerified Question#3
3. Minimum Boxing Area
Category: Binary search coding problem# Question Design a data structure to maintain a dynamic set of points on a 2D coordinate plane. Support operations to insert points, remove points,...Input: List Output: Integer
codingMediumVerified Question#4
4. Reverse Segment of Linked List
Category: Linked list coding problem# Question Given a singly linked list, reverse the second half of the list and then interleave the nodes from the first half and the reversed second...Input: Linked list Output: Computed result
codingMediumVerified Question#5
5. Unpainted Segments
Category: Binary search coding problem# Question You are given a range [A, B] and a sequence of painting operations. For each operation [L, R], calculate the total length of unpainted...Input: Array of intervals Output: Computed result
codingMediumVerified Question#6
6. Running Tests With Failing Pairs
Category: Algorithm coding problem# Question You are given a set of test cases and a black-box function runTests() that accepts a subset of these test cases and returns whether...Input: List Output: Integer
codingMediumVerified Question#7
7. Connected Crop Allocation
Category: Grid/matrix coding problem# Question You are given an M x N garden grid and a list of crops, each requiring a specific number of plots. The total number of plots required by...Input: 2D grid Output: Computed result
codingMediumVerified Question#8
8. [CodeSignal] Maximum Zero-Sum Triplets
Category: Array coding problem# Question You are given an array A of integers. A triplet is a sequence of three consecutive elements. A triplet is called zero-sum if the...Input: Array Output: Computed result
codingEasyVerified Question#9
9. [CodeSignal] Coin Table Game
Category: String coding problem# Question A player is playing a game in which coins are placed on and removed from a table. The game consists of multiple rounds. At the beginning...Input: String Output: Computed result
codingMediumVerified Question#10
10. Longest Match Tokenizer
Category: Array coding problemYou are given a text string text and a dictionary array where each element is in the format "<key>:<id>". Here key is a token string and id...Input: Array Output: Computed result
codingHardVerified Question#11
11. Dual Extremes Queue
Category: Queue-based coding problemDesign a StreamBuffer class that buffers a stream of integer latency samples in FIFO order and supports O(1) access to both the minimum and maximum...Input: Integer(s) Output: Integer
codingMediumVerified Question#12
12. Daily Branch Pruning
Category: Tree coding problemA file system manages a directory tree. Each day, all leaf directories (those with no child directories) are simultaneously removed. Directories that...Input: Array Output: Array
codingMediumVerified Question#13
13. Path Router
Category: Algorithm coding problem# Question Design a PathRouter class that maps URL-like path patterns to handler names. Patterns may contain wildcard segments (*) that match any...Input: Number(s) Output: Computed result
codingMediumVerified Question#14
14. Frequency Merge Tree
Category: Tree coding problem# Question Given a string, build a Frequency Merge Tree as follows: 1. Count the frequency of each character in the string. 2. Create a leaf node...Input: String Output: Computed result
codingHardVerified Question#15
15. Expression Simplifier
Category: String coding problemGiven an algebraic expression string containing single lowercase-letter variables, the operators + and -, and parentheses ( and ), simplify...Input: String Output: Computed result
codingMediumVerified Question#16
16. Largest Island Perimeter
Category: Grid/matrix coding problemYou are given an 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 Output: Computed result
codingHardVerified Question#17
17. Interval Coverage Counter
Category: Interval-based coding problemGiven a list of closed intervals on the integer number line, build a data structure that efficiently answers point-coverage queries. A closed...Input: List Output: Computed result
system designSeniormessaging#1
1. [OA] Messaging Queue — building a scalable message handling system for Google Chat
Google Chat requires a reliable messaging system to handle messages between users effectively. A simple message queue can be implemented to ensure that messages are processed in the order they are received. Problem Statement: Design a MessageQueue class that allows enqueuing and dequeuing messages, ensuring that all messages are processed in FIFO order. Class Signature:class MessageQueue: - def __init__(self): — initializes the message queue. - def enqueue(self, message: str) -> None: — adds a message to the queue. - def dequeue(self) -> str: — removes and returns the oldest message from the queue. If the queue is empty, raises an exception. Example 1: Input: msg_queue = MessageQueue(); msg_queue.enqueue('Hello'); msg_queue.enqueue('World'); msg_queue.dequeue() Output: 'Hello' Constraints: - The message length is at most 10^5 characters.
system designSeniorapi design#2
2. [OA] RateLimiter — controlling API request rates for Google Cloud services
As Google Cloud offers APIs to developers, it's essential to manage the rate of requests to prevent abuse. A rate limiter needs to enforce a maximum number of requests per time frame. Problem Statement: Design a RateLimiter class which limits the number of API requests per second. Class Signature:class RateLimiter: - def __init__(self, requests_per_second: int): — initializes the rate limiter with the specified maximum requests per second. - def allow_request(self, user_id: str) -> bool: — returns True if the request is allowed according to the rate limit, otherwise False. - def reset(self, user_id: str) -> None: — resets the request count for a specific user. Example 1: Input: RateLimiter(2); rate_limiter.allow_request('user1') Output: True Input: rate_limiter.allow_request('user1') Output: True Input: rate_limiter.allow_request('user1') Output: False Input: rate_limiter.reset('user1') Constraints: - 1 <= requests_per_second <= 100 - A user can make at least one request.
codingHarddynamic programming#3
3. [OA] Longest Increasing Subsequence — optimize user recommendations in Google Play
Google Play wants to provide the best app recommendations based on user preferences. The longest increasing subsequence can be used to find sequences of user interests. Problem Statement: Given an integer array nums, return the length of the longest increasing subsequence. You need to implement a function that computes this efficiently. Method Signature:def longest_increasing_subsequence(nums: List[int]) -> int: — returns an integer representing the length of the longest increasing subsequence. Example 1: Input: [10, 9, 2, 5, 3, 7, 101, 18] Output: 4 Explanation: The longest increasing subsequence is [2, 3, 7, 101], so the length is 4. Constraints: - 1 <= len(nums) <= 2500 - -10^4 <= nums[i] <= 10^4.
codingHardgraph#4
4. [OA] Dijkstra's Algorithm — optimizing the Google Maps routing engine
Google Maps needs to find the shortest path between locations efficiently. Imagine you have a graph representing the streets of a city where the nodes are intersections and edges represent the road segments with weights signifying travel time. Problem Statement: Implement a function that takes a graph represented as an adjacency list and returns the shortest path from a given starting node to all other nodes using Dijkstra's algorithm. The graph is represented as follows: graph: Dict[str, List[Tuple[str, int]]]. Method Signature:def dijkstra(graph: Dict[str, List[Tuple[str, int]]], start: str) -> Dict[str, int]: — returns a dictionary with the shortest distance from the start node to all other nodes. Example 1: Input: { 'A': [('B', 1), ('C', 4)], 'B': [('A', 1), ('C', 2), ('D', 5)], 'C': [('A', 4), ('B', 2), ('D', 1)], 'D': [('B', 5), ('C', 1)] }, 'A' Output: {'A': 0, 'B': 1, 'C': 3, 'D': 4} Explanation: Starting from A, the shortest path to B is 1, to C is 3, and to D is 4. Constraints: - 1 <= len(graph) <= 10^4 - 1 <= number of edges <= 10^4 - All weights are positive integers.