Free preview

What the Graders Actually Check

An auto-graded assessment measures three things and nothing else: whether your function returns the right answer on inputs you never see, whether it finishes inside a time limit, and how many of those inputs it got through before the clock ran out. Everything you might want it to notice, that your approach was sensible, that you nearly had it, that the failing case is a one-character fix, is invisible.

That narrowness has consequences worth internalising, because they are the difference between a candidate who scores 4 out of 4 and one who scores 2 and cannot explain why.

Hidden tests are where the marks are

You are typically shown two or three sample cases and graded on twenty or thirty. The samples are illustrative. They are chosen to explain the problem, which is close to the opposite of being chosen to break your code.

The hidden set does the breaking, and it is boringly predictable in what it reaches for:

  • The empty input. An empty list, an empty string, zero orders.
  • The single element. Where a loop comparing i against i - 1 never runs, or runs once with a negative index.
  • Everything identical. All prices equal, all timestamps equal, which turns a sort into a question about stability and a tie-break into a question about whether you defined one.
  • The maximum size in the constraints. Not a large input, the large input, sized so that the intended complexity passes and the next one up does not.
  • The pathological ordering. Already sorted, reverse sorted, or the arrangement that turns a hash map into a linked list.

Writing those five cases yourself before you submit costs three minutes and is the single highest-return habit in the format. You cannot see the hidden tests, but you can see the constraints, and the constraints are where the hidden tests come from.

Tip

Read the constraint block first, before the problem statement. It tells you the intended complexity, which usually tells you the intended technique, which is most of the solution.

"Suboptimal solutions fail" is a time limit

One widely reported assessment warns that "suboptimal solutions fail", and candidates read that as a stylistic preference. It is not. It is a wall-clock limit on the harness, chosen so that a solution one complexity class above the intended one does not finish.

The arithmetic is worth doing once. Suppose n=105n = 10^5 and the limit is a few seconds.

n2=1010operationsnlog2n1.7×106operationsn^2 = 10^{10} \quad \text{operations} \qquad n \log_2 n \approx 1.7 \times 10^6 \quad \text{operations}

At roughly 10710^7 simple operations per second in interpreted Python, and around a hundred times that in compiled C++, the second finishes comfortably in either and the first finishes in neither. There is no partial credit for being close: a quadratic solution to a problem with n=105n = 10^5 scores whatever the small tests are worth and nothing else.

This is why the constraint block is the most information-dense part of an assessment problem. A bound of n20n \le 20 is asking for exponential search. n2000n \le 2000 tolerates quadratic. n105n \le 10^5 means sorting, a hash map, a heap or a single pass. n109n \le 10^9 means you are not iterating over nn at all and the answer is arithmetic or binary search.

Worked example: reading a bound backwards

A problem gives you up to 2×1052 \times 10^5 orders and asks for the maximum number of them live at any instant. Two readings of that bound:

  • Quadratic, checking every order against every other, is 4×10104 \times 10^{10} comparisons. Ruled out by the bound alone, before you have thought about the problem.
  • Sorting the 4×1054 \times 10^5 start and end events and sweeping through them once is nlognn \log n, about 7×1067 \times 10^6 operations. Comfortable.

The bound did not just eliminate an approach, it named the technique: sort the endpoints and sweep. You reached that in fifteen seconds without reading the statement carefully.

What the grader cannot see, and who checks it later

The auto-grader has no opinion about your variable names. The next round does. Some firms state plainly that code is read after the tests pass, longer data assessments have carried a clean-code requirement in the brief itself, and one well-known onsite is built around layering new requirements onto the solution you already wrote, which is a direct test of whether the first version can be modified at all.

So the format asks for two things that pull in opposite directions: get to correct fast, and leave behind something a person can extend. The next section is about doing both, because they conflict less than they appear to.

Test your knowledge

An assessment problem states \( n \le 2 \times 10^5 \) and a time limit of a few seconds. What does the bound rule out before you have read the statement?
Your solution passes every sample case but scores 6 of 20 on submission. What is the most likely cause?

Keep reading Programming for Quantitative Developers

25 lessons in this course, and every other premium course, on one subscription.

  • Every lesson in every course, with the worked examples and interactive simulators
  • Graded questions on every lesson, with explanations for the wrong answers as well as the right one
  • The trainers, timed assessments and brainteaser library that go with them