Skip to content
Preptima
mediumCodingEntry

Your solution passes the sample tests and fails hidden ones. How do you find the edge case without seeing the tests?

Turn each constraint into a test: empty input, one element, the maximum size, duplicates, negatives, totals that overflow a 32-bit integer and inputs big enough to time out. Then compare your solution with a brute force on small random inputs; the first input where they disagree is your missing hidden test.

5 min readUpdated 2026-10-10Target archetype: Big Tech

Answer

Short answer

Stop guessing and generate the test. When hidden test cases fail and the samples pass, read the constraints and turn each one into an edge case: empty input, a single element, the maximum size, duplicates, negative values, totals that overflow a 32-bit integer, and inputs large enough to time out. If that list does not find it, write a slow but obviously correct brute force and compare it with your solution on many small random inputs. The first input where they disagree is your missing hidden test.

Was this answer helpful?

Likely follow-ups

  • Your brute force and your solution agree on ten thousand random inputs, yet a hidden test still fails. What do you suspect next?
  • The only verdict you get is time limit exceeded on the last few tests. How do you work out which loop is too slow?
  • Why generate random inputs from a tiny value range, such as minus five to five, rather than the full stated range?
  • The input contains many test cases in one file and only later ones fail. What kind of bug does that point to?

Related questions