By devs, for devs.

Open-source interview prep.

Get it for Windows Mac coming soon

free · no account · GPL-3.0

No. 121Easy

Best Time to Buy and Sell Stock

You get prices, where prices[i] is one stock's price on day i.

Buy once, then sell once on a later day. Return the most you can make, or 0 if no trade makes money.

Example 1
prices = [9, 4, 6, 2, 8, 5]
→ 6

Buy at 2 on day 3, sell at 8 on day 4.

Constraints
1 ≤ prices.length ≤ 10⁵
0 ≤ prices[i] ≤ 10⁴
High-Level Design

Design a URL shortener

Turn any long link into a short one, and send everyone who opens the short link to the original, quickly.

Requirements
  • Make a short link for any long link
  • Opening it redirects at once
  • Far more opens than new links
Out of scope

Accounts, custom names, analytics pages.

ML System Design

Design a video recommendation system

When someone opens the app, fill their feed with videos they will actually want to watch.

Requirements
  • A fresh feed every time it opens
  • New videos can be shown on day one
  • Learns from what people watch and skip
MediumInherited project

Spreadsheet Formulas

Fix the reported bugs

Users report wrong answers, and four tests fail at the start. Make them pass without breaking what works today.

The project

A small spreadsheet engine someone else wrote. People type numbers and formulas into cells, and it shows what each one works out to.

Behavioural

Tell me about a time you disagreed with your manager

One real story: what was at stake, what you did, and how it ended.

Your story
A release date, and tests that weren't ready.
solution.py Python 3 Ln 1, Col 1
Reply to Sam…RunEnd
Not run yet All 24 tests passedExamples 2/2Hidden 22/22
Testssheet.pyLn 13, Col 9
AssistantFastStrong
NotesSituationTaskActionResult
You0:00

Reply to Sam…End
44:37left of 45 min
Sam
Interviewer · Standard
Speaking

Transcript

questions

companies

        Asked at

        Questions

          Practise.

          Runs on your computer.

          Medium

          3Sum

          Given a list of whole numbers nums, find every set of three values, from three different positions, that adds up to zero. List each set once.

          Example 1
          Inputnums = [4, -2, -2, 1, 3]
          Output[[-2, -2, 4]]
          Hint 1 0:00

          Start with three nested loops over the list. How many triples does that check, and how many of them could be the answer?

          1 of 3 hints
          solution.py Python 3
          Not run yet 0/24

          Be curious.

          Sam asks. You figure it out.

          High-Level DesignDesign a rate limiter
          SamMentor
          Listening

          One user sends a thousand requests a second. Where would you stop them?

          Reply to Sam

          Interview out loud.

          SamInterviewer · Standard
          Speaking
          41:20left of 45 min
          41:20left of 45 min
          End

          Then the report.

          Interview report

          Best Time to Buy and Sell Stock

          EasyPython 344 of 45 minVoiceStandard interviewer
          Overall signal
          Lean hire
          No hire · Lean no hire · Lean hire · Hire · Strong hire

          Reached the one-pass idea after one nudge and wrote it cleanly, but ran the tests before tracing an example.

          Strongest CodingWeakest Testing
          Your skills
          • Started with Try every pair of days. Found the running low only after Sam asked What would you track as you walk the prices?

            Approach ▸ 5:23
          • One loop, two clear names, nothing extra. The second run passed all 24 tests with no change to the idea.

            Coding ▸ 24:10
          • Said I think that's it and pressed Run without tracing an example. The first run passed 0 of 24.

            Testing ▸ 29:10
          • One pass, so linear time, and constant space. Both right, but only once Sam asked.

            Approach ▸ 5:39
          • Talked the idea through clearly, then went quiet for most of the first five minutes of coding.

            Coding ▸ 16:00

          Strengths

          Readable codeCoding ▸ 24:10

          One loop, clear names, nothing extra.

          Correct complexityComplexity analysis ▸ 5:39

          Linear time and constant space, both right.

          Where to focus

          1
          Test before saying doneTesting ▸ 29:10

          Trace one normal and one edge case aloud before you run anything.

          2
          Look for the one pass soonerProblem solving ▸ 5:16

          Ask what you could keep as you walk the input before trying every pair.

          How the time went44 of 45 min used · Approach and Testing ran 5 min over
          Planned
          IClar. 4Approach 9Coding 15Testing 6Follow 6W
          Actual
          39+2146+342
          Tests
          0/2424/24

          It’s all in the repo.

          Every question is a file. Every solution runs against every test.

          Python
          C++
          Java
          JavaScript
          GPL-3.0
          Get it for Windows Mac coming soon

          free · no account · GPL-3.0