Passing a Codility test: what the score really measures
Codility is known for its two-part scoring: a correct but slow solution earns only half the points. This guide explains the grading, the recurring tasks and how to prepare.
A Codility test contains 1 to 3 tasks to solve in 60 to 120 minutes. Each task is graded on two axes: correctness (functional tests, including edge cases) and performance (tests on large inputs, with an expected complexity stated in the task). To score 100% you must handle every special case and meet the required complexity, usually O(n) or O(n log n).
The Codility grading, explained
Every task states an expected complexity, for instance 'expected worst-case time complexity is O(N)'. Treat it as an instruction: an O(N²) solution passes the correctness tests and fails all performance tests, often 50% of the grade.
Correctness tests check edge cases: empty array, single element, extreme values (up to ±2,147,483,647), duplicates, all elements identical. Performance tests send arrays of 100,000 elements or more.
The recruiter's report lists every named test (such as 'extreme_min_max' or 'large_random'), so they see exactly where your solution broke.
The lessons and tasks that keep coming back
Codility publishes free 'Lessons' that hiring tasks closely resemble. The most frequent: Time Complexity (FrogJmp, PermMissingElem, TapeEquilibrium), Counting Elements (FrogRiverOne, MaxCounters, MissingInteger), Prefix Sums (PassingCars, GenomicRangeQuery, MinAvgTwoSlice), Sorting (Distinct, Triangle, MaxProductOfThree), Stacks and Queues (Brackets, Fish, StoneWall), Leader (Dominator, EquiLeader) and Maximum Slice (MaxProfit, MaxSliceSum).
Hiring tasks are often variants of these lessons in a different costume: a statement about 'deliveries' or 'sensors' hides a prefix sum or a counter.
Codility-specific traps
Integer overflow: sums of N elements up to 10⁹ exceed int in Java, C# and C++. Switch to long as soon as you add things up.
Empty or single-element arrays: many solutions that read A[0] or A[1] crash on these tests.
Formula instead of loop: for PermMissingElem or FrogJmp, an O(1) formula removes any performance risk.
Not testing before submitting: Codility has no hidden samples in the text; create your own test cases in the editor ('Test' button) before submitting, with an empty array and a large one.
How to train effectively
Do all lessons 1 to 8 on the Codility site, aiming for 100% each time: the report says precisely which tests fail, which is the best way to learn edge cases.
For each task, write the expected complexity first, then the algorithm in two lines, then only the code. This habit prevents 80% of performance failures.
Finish with a mock test in real conditions: two tasks in 60 minutes, no documentation.
With Coding Solutions
On a Codility lesson, the Coding Solutions extension explains the approach that meets the required complexity, flags the edge cases (empty, overflow, duplicates) and gives commented code in your language. You understand why a 'large_random' test fails instead of guessing.
To review linear search, sorting and edge cases, see also our explained CodinGame solutions.
Frequently asked questions
How does Codility compute the score?
Each task is graded as a percentage, averaging correctness tests and performance tests. The overall score is the average of the tasks. A correct but too slow solution often caps at 50–60%.
Are hiring tasks the same as the lessons?
Not identical, but very close: same techniques, different wording. Mastering lessons 1 to 8 covers the large majority of hiring tests.
Which language should I use on Codility?
The one you know. Python is accepted everywhere and its relative slowness is factored into Codility's time limits; an O(n) Python solution passes the performance tests.
Can I see my result after the test?
No, candidates don't see the report; only the recruiter does. On practice lessons, however, the full report is visible.