Given 2 lists, find the common items in both lists. 这道题要求找出两个列表中的公共元素,最直接的做法是先遍历其中一个列表并用哈希集合记录出现过的值,再扫描第二个列表,判断哪些元素也出现在集合中。这样可以把查找从线性时间降到接近 O(1),整体复杂度通常…
Problem Statement Given two strings A and B , return the 0-based starting index of the first contiguous substring in A that is a permutation (anagram) o…
You are building an in-memory, single-threaded analytics service for ChatGPT chat sessions. It ingests a real-time, globally non-decreasing stream of in…
Given a web page, we want to annotate text segments that may overlap. (One example is Google Docs, where you can highlight some text and add a comment.)…
Assume that Airbnb decided to enable search on user reviews. In order to make the search better, you need to tag specific words in the review. The searc…
Given an integer array nums of length n and an integer target , find three integers in nums such that the sum is closest to target . Return the sum of t…
Build a simple class that implements a basic in-memory service that: Records a song play event for a given song id Returns play counts for individual so…
An infected plant spreads infection to neighboring plants. If a plant is surrounded by D infected plants, it also becomes infected. How many days until…
You are given a matrix whose elements are initially set to 0 and a starting position (startRow, startCol) (0-based indexing). Fill the matrix with incre…
Build a reservation system for a predefined set of conference rooms given as a list of room IDs [roomA, roomB, …] . It should have a method like sched…
You have a dataset which contains examples labeled with different classes (single-label, multiple classes); for example, an animal image classification…
Social Network Implement follow , unfollow , snapshot , and is_following . The snapshot captures the current state of all relationships and returns an i…
We are designing a system for officers to check out a body worn camera from a pool of available cameras. We need an object to store a collection of came…
In this exercise, you will build your own version of a Domain Name System (DNS) resolver, the system your computer uses to translate a domain name into…
You are given a partially implemented algorithm for Extremely Randomized Trees , a decision-tree ensemble method introduced by Geurts et al. (2006). You…
Objective Given a list of daily stock prices, return the three stocks with the highest average price. Implementation Implement the function get_top_stoc…
In the Google Drive architecture, a folder hierarchy is maintained where folders can be nested within one another (folders 1 to n). Each folder has a sp…
Implement a function that merges multiple sorted integer streams into a single sorted list. interface SortedIntegerStream { int next(); // get the integ…
The notebook platform at Stripe is based on Jupyter. It does not perform well with a large number of active connections, so we want to route developers…