There is a plot (grid-like land) with each spot having a specified elevation. Within this plot there are two villages that need water delivered to them….
Amazon sells millions of products on its website, and for better customer experience, it wants to show a widget with the most popular items bought on th…
Design a String Compress(string input) system. The system should support compressing an input string and later decompressing it back to the original for…
Amazon wants to build a lottery system. When a customer purchases items worth between $1 and $100, they are entered into the lottery. Customers who purc…
Amazon is releasing a feature called “Stuff Your Friends Are Buying” . Implement a function that returns stuff that a person’s friends are buying that t…
Write a program which takes an array of strings and a set of strings, and returns the starting and ending indices of a shortest subarray of the given ar…
Online coding judge Registered users Contest has a start time and end time (next Sunday 10 AM to 5 PM PST) Upon start, users get access to 10 problems U…
Design a new service for users to create playlists and store songs in them. Functional requirements Users can create any number of playlists. Users can…
Implement the functionality of the “find” command in UNIX as an API that returns a list of files matching the provided search parameters. The search sho…
S3 is a publicly accessible HTTP service. It supports PUT of a key (URL) that stores a value. It supports GET that retrieves the value. The goals of S3…
Write a function that takes a string input. The string will be a file path name (for example, /usr/bin ). The path may contain special directories . (re…
Implement a trie (prefix tree) with the following methods: Trie() initializes the trie object. void insert(String word) inserts the string word into the…
Given a sorted array arr = [1, 2, 3, 10, 11, 12] , find k = 3 closest elements around target m . 这道题的核心是在有序数组中找出与目标值 m 距离最近的 k 个元素。由于数组已经排好序,通常可以先用二分定位目…
Given a data stream of CPU utilization values as doubles: 10.0 , 20.5 , 35.0 , 45.0 , 20.0 , 19.0 , 18.5 , … Find the median of the data stream. The e…
Imagine you’re interacting with Alexa. When you command Alexa to “acquire a certain item”, it begins to retrieve information from a variety of sources,…
The Unix find command allows you to search for files under a given directory. You can specify criteria for files you are interested in. Imagine that you…
Given a dictionary of words and a pair of words. For the pair, display the possible word chain using the input as the starting and ending words. Print a…
Question: Sellers buy items in Walmart during sale events and sell them on Amazon to make money. You have to help a seller make maximum profit for their…
Build a system that calculates the price of a customer’s order in a furniture store. Pricing rules are as follows: Used items get a 20% discount off the…