Onsite Algorithms: Stock Profit, Scale-Out & Line Math
- Solve the stock profit problem in one pass, then the unlimited-trades version
- Split the stock scan across threads or machines with mergeable chunk summaries
- Find y = a*x + b at four distinct indices by matching two hash maps
- Explain the O(n^2) pair split out loud and guard the products against overflow
Most Zoox technical screens are trivia plus a class design problem. The onsite is where the classic algorithms show up. Zoox's own internship page says its coding questions look like the exercises on platforms like LeetCode, and full-time loops match that. One problem family keeps coming back. Best time to buy and sell stock turns up in onsites from 2021 through 2026, and a mid-level candidate in September 2025 called it the hardest question of the day.
What sets the Zoox version apart is the scale-out at the end. Once your single pass works, interviewers have asked you to multithread it (2024), or to split data that won't fit in memory across N machines and write the pseudo code (2023). This lesson works that family first, then the y = a*x + b task that shared a round with it. Older problems from 2018 to 2024 are in Older Practice Problems.
What the Zoox onsite coding round looks like
Expect a shared online editor where your code has to run. Most teams let you pick C++ or Python. Go was accepted in an October 2026 loop. Teams that ship code onto the vehicle may switch you to C++ for the onsite even after a Python screen, as one 2024 candidate found out. An October 2026 onsite opened its first round with language trivia and then a coding problem, so a few minutes of quick questions in your language may come first.
The solutions below are Python. The editor also has C++, Java, Go, JavaScript and Ruby starters for every problem. If your team might move you to C++, write the stock and line problems in C++ at least once. The line task is where overflow bites: a product of two values near a billion doesn't fit in a 32-bit int.
Each problem here comes down to one small summary. Stock profit keeps the lowest price so far, and its parallel version carries a lowest price, a highest price and a best profit per chunk. For the line task you store every product a*x in a map, keyed to the pair of indices that made it.
Best time to buy and sell stock, then scale it out
Candidates describe it from a July 2021 front-end loop through a September 2025 mid-level onsite, and it was still being asked in May and June 2026. The 2025 candidate got the classic version: daily prices, one buy and one sell, maximum profit. Their example was 4, 3, 2, 6, 1, 7, which gives 6. An L3 loop in April 2024 asked the unlimited-trades version next, then multithreading for both.
The scale-out ask runs from 2021 to 2024. A 2021 loop kept "distribute a problem across multiple hosts" as a backup question. In October 2023 a senior C++ candidate, who didn't name the base problem, was told the data doesn't fit in memory and asked to split the work across N machines in pseudo code. They wrote multithreaded C++ instead and heard back "not senior enough". A November 2023 round titled "Algorithm in pseudo code" asked how to deploy the stock answer on many machines.
Best Time to Buy and Sell Stock
Problem
prices, where prices[i] is the price of one stock on day i. Choose one day to buy and a later day to sell.Return the largest profit you can make. If no trade makes money, return
0. A list with fewer than two prices also returns 0.Buy at 1 on day 4 and sell at 7 on day 5. Buying at 2 and selling at 6 only makes 4.
Walk the prices once. Keep the lowest price seen so far, and at each day compare selling today against that low.
Best Time to Buy and Sell Stock
Click "Run" to execute your code
Four values with y = a*x + b at distinct indices
In an April 2024 L3 loop, the stock questions were followed by "a math question related to y = mx+c" in the same round. A November 2023 loop gives the shape and the intended answer. You find values that satisfy y = ax + b, and the best solution builds a map of y - b, another of a*x, and looks for equal values. A May 2026 technical screen asked something similar: four values at distinct indices, with cases where none exist and products too wide for 32 bits.
The version below is something like the direct reading: one array, four different positions, does any choice satisfy the equation. It's the same kind of pair-matching as 4Sum, so practicing this covers both.
Four Values on a Line
Problem
nums. Decide whether there are four different indices i, j, k and l such that nums[i] == nums[j] * nums[k] + nums[l].Read it as y = a*x + b, with y, a, x and b each taken from a different position. Values may repeat in the list, but an index can be used only once. Return
true if such a choice exists and false otherwise.7 = 2 * 3 + 1, using indices 2, 0, 1 and 3.
Rearrange to y - b = a * x. Store every a * x pair product in a map, then walk every (y, b) pair and look up y - b.
Four Values on a Line
Click "Run" to execute your code
Common questions
What coding questions does Zoox ask at the onsite?
Best time to buy and sell stock is the one candidates report most, from 2021 through 2026. It comes with follow-ups that multithread it or split it across machines. The y = a*x + b task followed it in the same round in a 2024 loop and came up again in a May 2026 technical screen.
Is the Zoox coding interview LeetCode style?
The onsite mostly is. Zoox's internship page compares its questions to LeetCode exercises, and the problems above match. The technical screen is different for many teams. It's usually language trivia followed by a practical class design problem that has to run, covered in the screen problems lesson.
Which language should I use?
C++ or Python for most teams, and Go was accepted in an October 2026 loop. Vehicle teams may ask for C++ at the onsite even after a Python screen (2024). Language trivia follows whatever you pick, so choose the one you can answer quick questions about.
How should I practice these?
Code each base problem from a blank file in under ten minutes, then spend the rest of the session on the follow-ups. Explain the stock chunk summary out loud as if you were writing the pseudo code for N machines. Write the line task once in C++ with 64-bit products.
Key Takeaways
- ✓Stock profit is the recurring Zoox onsite algorithm. Finish the one-pass answer fast and save time for the scale-out.
- ✓For N machines, each chunk returns its lowest, highest and best. The merge adds the cross trade, right highest minus left lowest.
- ✓Rewrite y = a*x + b as y - b = a*x, map pair products to index pairs, and check that all four indices differ.
Zoox interview guideKnow what Zoox asks before you walk in.
21 coding · 4 system design · 30 behavioral questions
Get their questions first.
InterviewLegend is independent and not affiliated with or endorsed by any company it covers.