← All questions
HardCoding
First Missing Positive
Asked at
FactSet Research Systems Inc.
ServiceNow
1Give yourself 5 minutes
2Answer out loud, not in your head
3Then compare with the answer below
0
Stuck? Show a way to structure it+
- 01Use one through n as relevant values.
- 02Place each valid value in its home index.
- 03Guard swaps against duplicates.
- 04Scan for the first missing home value.
- 05Return n plus one when all homes are filled.
Reference answer
Then expect these follow-ups
Why do values larger than n not matter?
Tests: correctness reasoning
How would you preserve the original array?
Tests: follow-up reasoning
Free to read · better with Enzo
Practice this out loud with Enzo
Enzo runs it as a mock interview, pushes back with follow-ups, and grades you on the rubric.
Next question