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 designSeniorapi design#1
1. [OA] Distributed Config Manager — implement a centralized management system for application configurations across Google’s services
In modern cloud architectures, managing application configurations centrally is critical for consistency and flexibility. Design a ConfigManager class that allows applications to store and retrieve configurations using a key-value pair approach.- class ConfigManager: - def set_config(self, key: str, value: str) -> None: Store a configuration value with the associated key. - def get_config(self, key: str) -> str: Retrieve the configuration value for the specified key. - def delete_config(self, key: str) -> None: Remove the configuration entry. - def list_configs(self) -> List[Tuple[str, str]]: Return a list of all configurations as key-value pairs.Example 1: Input: config_manager = ConfigManager() config_manager.set_config('feature_x_enabled', 'true') Output: None Explanation: Configuration is stored successfully.Constraints: - 1 <= key.length <= 100 - 1 <= value.length <= 100 - Total number of configurations will not exceed 1000.
system designSeniordistributed systems#2
2. [OA] Circuit Breaker — implement a fault tolerance mechanism for Google’s microservices
In microservices architecture, a Circuit Breaker pattern is used to prevent an application from repeatedly trying to execute operations that are likely to fail. Design a CircuitBreaker class that manages the state of the circuit breaker and the logic to handle requests based on its state.- class CircuitBreaker: - def call(self, request: Callable[[], T]) -> T: Executes a request and returns the result or raises an exception if the circuit is open. - def reset(self) -> None: Resets the circuit breaker state.Example 1: Input: cb = CircuitBreaker() result = cb.call(lambda: my_service_call()) Output: result from my_service_call() or raises an exception Explanation: The method either returns the result of the service call or throws an exception if the circuit is open.Constraints: - The circuit contains a specified timeout and threshold for failures.
system designSeniorci cd#3
3. [OA] CI/CD Pipeline — design an efficient build and deployment process for Google services
In order to ensure continuous integration and delivery, it is necessary to design a CI/CD pipeline that automates testing and deployment for various Google services in a scalable manner. Implement a class CICDPipeline that manages builds and deployments, handles test executions, and keeps track of build histories.- class CICDPipeline: - def build(self, service_name: str) -> bool: Returns True if the build is successful, otherwise False. - def test(self, service_name: str) -> bool: Returns True if the tests are successful, otherwise False. - def deploy(self, service_name: str) -> bool: Returns True if deployment is successful, otherwise False. - def get_build_history(self) -> List[str]: Returns a list of build history.Example 1: Input: pipeline = CICDPipeline() pipeline.build('ServiceA') Output: True Explanation: The build for ServiceA was successful.Constraints: - 1 <= service_name.length <= 100 - Number of services managed by the pipeline will not exceed 1000.
codingMediuminfra#4
4. [OA] Dockerfile Optimization — enhance container build efficiency for Google Cloud services
To optimize the deployment of applications using containerization, it is crucial to enhance the build efficiency of Docker images. This is particularly important for scaling Google services to ensure quicker deployment and reduced resource utilization. Given a Dockerfile, optimize the instructions to minimize the image size and improve build speed.- def optimize_dockerfile(original: str) -> str: Return the optimized Dockerfile as a string.Example 1: Input: FROM python:3.8 RUN apt-get update && apt-get -y install git COPY . . RUN pip install -r requirements.txt Output: FROM python:3.8 COPY requirements.txt . RUN pip install -r requirements.txt COPY . . Explanation: The instructions are reordered to only install packages once.Constraints: - 1 <= original.length <= 1000 - The Dockerfile syntax will remain valid.