Given a file system: root (id=1) dir (id=2) file1 (id=4): 100b file2 (id=5): 200b file3 (id=3): 300b It will be represented as follows: Filesystem = { 1…
Write a function that, given an x, y coordinate of a land cell, returns all water cells that touch that island. 这题的核心是先从给定的陆地坐标出发,遍历整座岛屿,再收集与岛屿边界相邻的所有水格…
Create an online match-making algorithm that receives players and dispatches a call to a game server when it finds players with ratings close enough to…
Network of routers: each router has an (x, y) coordinate. A message can be broadcast from one router to another if the Euclidean distance between them i…
Restaurant Waitlist API Use your API to get a party from a FIFO waitlist. Your API needs to: add a party to the waitlist remove a party from the waitlis…
Input is a string and a maximum width length. If a word is too long to fit into one line, we change line and move it to the other line. Implement a Pyth…
Consider a deck of normal playing cards. A playing card is represented as a string, where the first part represents the rank (one of Ace A, 2, 3, …, 1…
Imagine you have an RPC server that produces log entries and you’re analyzing it offline. There are two entries for each call: one when the RPC starts a…
Given a company tree, calculate how many managers are paid less than the average salary of their direct and indirect employees? For example, consider th…
You are given a list of log messages, each associated with some source file which emitted them. struct LogMessage { string source_file; string message;…
Given a binary tree, compute the diameter of the tree. The diameter is the longest path between any two nodes in the tree. 这道题要求计算二叉树的直径,也就是树中任意两点之间最长路径…
Query: use the query to match the key. Key: label of each data slice. Value: the data itself. 1. Compute the similarity between query and key. query [1…
Can we assume the input is sorted or not? You can sort by the start time of each interval. Merge the overlapping meetings with a loop over the meetings….
Given a sequence S of N digits, find a subsequence of K digits such that the number formed by these K digits, in order, is the largest. 这道题要求从一个由 N 个数字组…
You are given a table of people with three columns: Name , Start , and End . Each row represents an interval for a person. Create a second table with co…
Let’s pretend we’re working on a computer vision project. In this project, librarians sent us videos of their bookshelves. Based on frames from these vi…