Return the word empty rather than reading a missing element.
Acceptance criteria
- 1.#out should show empty.
DSA Tutorial · Interview Patterns
These 10 tasks go with the How to Answer in an Interview chapter. 5 of them ask you to build something small from scratch; 5 give you code that is already broken and ask you to work out why. Set aside about 90 minutes for the whole set, though you can do them in any order.
Nothing here is marked by a person. When you press Submit, the editor checks your code against the points listed under each task and tells you straight away what passed and what didn't (you need a free account to submit). If you get stuck, there are hints, and a worked solution once you've had a go. The first 2 tasks are free; the rest are part of the practice plan.
If it's been a while since you read the chapter, here is how it starts: “You are not being marked on whether you produce the optimal solution. You are being marked on whether working with you would be pleasant and productive. Those are different tests, and the second one is easier to pass.” .
1.Handle an empty inputexercise · easy · 10 min
Return the word empty rather than reading a missing element.
Passes when: #out should show empty.
2.State the complexityexercise · easy · 10 min · practice plan
Report the time class of a single pass over the input.
Passes when: #out should show linear.
3.Test a single elementexercise · easy · 10 min · practice plan
Confirm the function works on a one-element array.
Passes when: #out should show largest 7.
4.Confirm before codingexercise · easy · 10 min · practice plan
Report whether duplicates are allowed before writing the solution.
Passes when: #out should show ask first.
5.Brute force then improveexercise · medium · 10 min · practice plan
Report what to offer when no optimal idea arrives immediately.
Passes when: #out should show brute force first.
6.Fix the empty input crashingbug fix · easy · 8 min
Math.max of nothing is negative infinity, not a useful answer.
Passes when: #out should show empty.
7.Fix the complexity claimed for nested loopsbug fix · easy · 8 min · practice plan
Two nested passes over the input are quadratic, not linear.
Passes when: #out should show quadratic.
8.Fix coding before clarifyingbug fix · easy · 8 min · practice plan
Starting without the rules risks solving the wrong problem.
Passes when: #out should show ask first.
9.Fix staying silent without an optimal ideabug fix · easy · 8 min · practice plan
A working slow answer beats no answer at all.
Passes when: #out should show brute force first.
10.Fix the untested edge casebug fix · medium · 8 min · practice plan
A single element must still produce a sensible answer.
Passes when: #out should show largest 7.
Between them these tasks cover Clarifying, Stating complexity and Testing edge cases.
Looking for a different chapter? See every practice set, or switch to the interview theory questions.