Mastering Codility Interview Questions

On this page
- What Is a Codility Assessment?
- How the Codility Test Works, Step by Step
- How Codility Scores Your Solution
- Codility Test Rules and Integrity Checks
- Common Codility Task Types
- Worked Example: A Codility-Style Problem in Py…
- Codility Python and Java Tips
- Codility Test Tips: A Time-Management Plan
- Set Up Your Environment Before You Click Start
- How to Practice for a Codility Test
- What Comes After the Codility Test?
- Frequently Asked Questions
A Codility invitation usually means a timed online coding test: a few programming tasks, one countdown clock, and automatic scoring against test cases you cannot see. Some companies also use Codility for live technical interviews. This guide explains how the Codility test works for candidates (based on Codility's own candidate FAQ and help center), how your code is scored, the task types that come up most often, a worked example in Python, and a practical time-management and setup plan so nothing about the platform surprises you on test day.
What Is a Codility Assessment?
Codility is a technical hiring platform. Employers use it in two main ways, and it helps to know which one you have been invited to:
- Screening assessments (Codility Screen, long known as CodeCheck). An asynchronous test you take on your own within a window the employer sets. Codility describes it as several problems where you write code, modify existing code, or answer technical questions. When you finish, your solutions are scored automatically and the results go to the employer. When people search for "Codility test" or "Codility assessment," this is what they mean.
- Live interviews (Codility Interview, formerly CodeLive). A collaborative video coding session with an interviewer, similar to pair programming. You can enter once the interviewer starts the session.
The employer chooses the tasks, the programming languages allowed, the time limit, and the integrity settings. Codility provides the platform. That is why two Codility tests from different companies can look quite different.
How the Codility Test Works, Step by Step
- Open the link before you start. The intro page shows the number of tasks, the time limit, the allowed languages, and the employer's assessment policies. You can read all of this and leave. The clock does not start until you press "Start."
- Start inside the testing window. The invitation says whether there is a deadline. Codility recommends taking the test within a day or two of receiving it. If you need more time, ask the test administrator.
- The timer covers the whole test. Codility says tests typically last between half an hour and two hours. The time on screen is for the entire assessment, not per task, and once you start you cannot pause or stop it.
- Work on tasks in any order. You can move freely between tasks without submitting. Code is saved automatically, and if you close or refresh the browser you resume where you left off.
- Run your code as often as you like. The built-in environment lets you edit, compile, and run your solution against the example test case, and you can add your own test cases.
- Submit each task when it is ready. After you click "Submit" on a task, you cannot change that solution.
- When time runs out, whatever is in the editor is submitted. That is why it matters that your code always compiles.
How Codility Scores Your Solution
This is the part most candidates misunderstand. According to Codility's candidate FAQ:
- Your code must compile. A final submission that does not compile earns no points for that task, so a working partial solution beats a brilliant one with a syntax error.
- Hidden test cases decide your score. After you submit, Codility runs your solution against multiple test cases that check correctness (whether you handle corner cases) and scalability (whether your code stays fast as the input grows).
- "OK" on the example does not mean you solved it. Clicking "Run" and seeing "OK" only confirms your code compiles and passes the one example. The example is not part of the actual assessment, which is how candidates can pass the example and still score 0%.
- Speed of finishing is not scored. Codility says the time you take to solve tasks does not factor into automated scoring. What matters is correctness and efficiency.
- Style can matter. Most tasks do not score coding style automatically, but some tasks are designed to, and the hiring team may manually review your code.
- You may or may not see your results. Some employers share results with candidates and others keep them confidential.
In short: think of each task as having two grades, "is it correct on every edge case" and "is it fast enough on the largest allowed input." An O(N²) solution can earn correctness points and lose most of the performance points.
Codility Test Rules and Integrity Checks
Codility's candidate FAQ is clear on the basics: you must work on your own and may not get help from other people during the assessment. Whether you may use other resources, such as documentation or your own IDE, depends on the policies shown in your test link. Unless a task says otherwise, you can only use the standard library of your chosen language.
On the employer side, Codility documents several integrity features. Which ones are active depends on the employer's settings:
- Similarity check. Codility cross-checks solutions against other submissions, solutions leaked online, and AI-generated solutions, and flags close matches for review. Codility says the check can recognize similarity even after identifiers are renamed or code is reformatted. It does not apply to every task type (for example, SQL, multiple-choice, and free-form tasks are excluded).
- Optional monitoring. Codility's help center describes photo ID verification, network IP checks, and proctoring features such as camera recording, snapshots, and screen sharing. Proctoring is optional and chosen by the employer. If your test uses the camera or screen sharing, you have to grant access before you can start, so you will know.
The practical takeaway: the only strategy that holds up is to be able to solve these problems yourself. Many companies follow a Codility screen with a live technical round, where you may be asked to walk through the code you submitted.
Common Codility Task Types
Codility says most screening tasks involve writing or modifying short programs, usually 10 to 20 lines. The tasks are chosen by the employer for the role, but the underlying skills are consistent. Codility's own free training lessons are organized around these topics, and they map closely to what shows up in tests:
| Topic | What it tests | Typical approach |
|---|---|---|
| Iterations and arrays | Loops, indexing, rotating or scanning arrays | Single pass, careful boundaries |
| Time complexity | Recognizing when O(N²) will time out | Replace nested loops with math or a lookup |
| Counting elements | Frequencies, missing or duplicate values | Hash set, dictionary, or counting array |
| Prefix sums | Range sums, balance points | Precompute running totals |
| Sorting | Distinct values, triangles, intersections | Sort first, then one pass |
| Stacks and queues | Bracket matching, "survivors" problems | Stack for nested structure |
| Leader and max slice | Dominant element, best subarray or profit | Boyer-Moore voting, Kadane's algorithm |
| Primes, sieve, GCD | Divisors, factorization, cycles | Loop to square root, Euclid's algorithm |
| Binary search | Minimizing a maximum, searching an answer range | Binary search on the answer |
| Caterpillar and greedy | Windows, pairs, interval choices | Two pointers, greedy with proof |
| Dynamic programming | Best path or score with choices | Table of subproblems |
Depending on the role, a test can also include bug-fixing tasks (with limits on how much code you may change), SQL tasks, multi-file project tasks, multiple-choice questions, and free-form written answers. Open-ended system design is harder to auto-grade, so if your process includes it, expect it to be discussed in a live round. Our system design interview guide for senior engineers covers that round.
Worked Example: A Codility-Style Problem in Python
Here is an original practice problem written in the Codility format, with the kind of constraints that separate a correct solution from a fast one.
The task
A warehouse records the net change in stock for each day in an array A of N integers. Write a function solution(A) that returns the length of the longest run of consecutive days whose changes add up to exactly zero. Return 0 if there is no such run.
Example: for A = [2, 3, -1, -2, 4, -4, 1] the function should return 5, because days 1 through 5 (3, -1, -2, 4, -4) sum to zero.
Assume N is an integer in the range [0..100,000] and each element is an integer in the range [-1,000..1,000].
Step 1: The brute force (correct but too slow)
Try every start day, keep a running total as you extend the end day, and record the longest run that hits zero. That is correct, but it is O(N²). With N = 100,000 that is roughly 5 billion additions, which would pass the small correctness tests and time out on the performance tests. On Codility, that often means a score well below 100% even though the logic is right.
Step 2: The insight
Let prefix[j] be the sum of the first j + 1 elements. The sum of days i + 1 through j equals prefix[j] - prefix[i]. That is zero exactly when the two prefix sums are equal. So the longest zero-sum run ends at j and starts right after the first earlier position with the same prefix sum. Store the first index where each prefix sum appears, and you can answer in one pass.
Step 3: The solution (O(N) time, O(N) space)
def solution(A):
first_seen = {0: -1} # a prefix sum of 0 "before" day 0
running = 0
best = 0
for i, change in enumerate(A):
running += change
if running in first_seen:
best = max(best, i - first_seen[running])
else:
first_seen[running] = i
return best
Step 4: Trace the example
| Day (i) | A[i] | Running sum | First seen at | Best so far |
|---|---|---|---|---|
| 0 | 2 | 2 | new (0) | 0 |
| 1 | 3 | 5 | new (1) | 0 |
| 2 | -1 | 4 | new (2) | 0 |
| 3 | -2 | 2 | 0, so run = 3 - 0 = 3 | 3 |
| 4 | 4 | 6 | new (4) | 3 |
| 5 | -4 | 2 | 0, so run = 5 - 0 = 5 | 5 |
| 6 | 1 | 3 | new (6) | 5 |
Step 5: Test the edges before you submit
Codility's own advice is to test empty, very small, and very large inputs and to think about the worst data the task allows. For this problem, add these custom test cases:
[]should return 0 (empty input).[0]should return 1 (a single zero is a valid run).[1, 2, 3]should return 0 (no zero-sum run).[5, -5]should return 2 (the whole array).- 100,000 zeros should return 100,000 (checks speed and the "whole array" case).
Two details are easy to miss: initializing first_seen with {0: -1} (without it, runs that start on day 0 are never counted) and storing only the first index for each sum (overwriting it would shorten the runs you find).
Codility Python and Java Tips
Codility lets you pick from the languages the employer allowed, and unless a task is language-specific, your choice does not affect your score. Pick the language you are fastest and most accurate in. Language-specific traps to watch for:
Python
x in some_listis O(N). Inside a loop it quietly makes your solution O(N²). Use asetordictfor membership checks.list.pop(0)andlist.insert(0, x)are O(N). Usecollections.dequefor queues.- Python's default recursion limit is about 1,000 frames, so a recursive solution can crash on a 100,000-element input. Prefer loops.
- Slicing (
A[i:j]) andsum(A[i:j])inside a loop copy data every time. Use prefix sums instead. sorted()is O(N log N), which is almost always fine. Sorting inside a loop is not.
Java
- Integer overflow is the classic Java failure on Codility. If sums or products can exceed about 2.1 billion, use
long. - Keep the provided method signature exactly as given. Codility says changing it means the assessment engine cannot run your program. You can add helper methods and imports from the standard library.
- Use
HashMapandHashSetfor lookups, and be aware of boxing costs in very tight loops. - If you write code in your own IDE (only if the test policy allows it), paste it back and click "Run" to confirm it compiles on Codility's compiler version, which is shown in the interface.
For broader language prep, see our Python developer interview preparation guide.
Codility Test Tips: A Time-Management Plan
- Read every task first. Codility itself recommends reading all task descriptions before starting so you can plan how to split your time. Start with the task you are most confident about.
- Budget your time. Divide the total by the number of tasks and reserve about 10 minutes at the end. With 3 tasks in 90 minutes, that is roughly 25 minutes per task plus a buffer.
- Get a correct version working first. A simple, correct solution that compiles earns correctness points. Then optimize if you have time.
- Read the constraints. The range of N tells you the target complexity. Around 100,000 or more usually means O(N) or O(N log N).
- Run early and often. Never leave code that does not compile, because whatever is in the editor gets submitted when the clock runs out.
- Test beyond the example. Add custom test cases for empty input, a single element, all duplicates, negatives, and the maximum values.
- Do not validate the stated assumptions. Codility says you do not need to check that the input matches the task's assumptions. Spend that time on edge cases inside the allowed range.
- Submit deliberately. Submitting a task locks it, so do a final read-through before you click.
Set Up Your Environment Before You Click Start
- Use a laptop or desktop. Codility says it does not support phones or tablets.
- Use a supported, up-to-date browser. Codility lists current versions of Chrome, Firefox, Safari, Opera, and Chromium-based Edge. If your test records video, takes snapshots, or requires screen sharing, use Chrome, which Codility names as the supported browser for recording features.
- Check your camera if the test needs it. If camera access is required, you cannot start until it is set up. Close other apps that use the camera and disable browser extensions that might interfere.
- Some tests require the Codility App. If yours does, you will be told to install it before you begin. Otherwise, no installation is needed.
- Block the full time in one sitting. The timer cannot be paused. If you lose power or internet, contact the test administrator and ask them to reopen your session.
- Ask for accommodations early. Codility's platform supports screen readers, keyboard navigation, and an accessibility mode with up to 400% zoom in the editor. If you need extra time, tell the test administrator before you start.
How to Practice for a Codility Test
- Take Codility's demo test. Codility offers a demo assessment so you can learn the editor, the "Run" button, and custom test cases before the real thing.
- Work through Codility's free lessons. The Codility developer training lessons cover the topics in the table above, each with practice tasks.
- Practice with real test cases. Interview Sidekick's coding practice lets you solve problems in Python or JavaScript and run them against real test cases in your browser, with solutions that walk from brute force to optimal. That brute-force-to-optimal habit is exactly what Codility's performance tests reward.
- Simulate the clock. Do two or three problems back to back in a fixed time block, with no pausing. Endurance and pacing matter as much as knowledge.
- Review common patterns. Our guides to Google coding interview questions and common FAANG interview questions cover many of the same algorithm patterns.
What Comes After the Codility Test?
A Codility screen is usually one step, not the whole process. If you pass, expect a live technical interview (sometimes in Codility's live interview environment) where you solve a problem while explaining your thinking, and often a behavioral round. Practice both:
- Explain your code out loud. Interview Sidekick offers AI mock interviews with feedback, so you can rehearse talking through a solution and answering follow-up questions. See our guide to preparing for a FAANG software engineering job and our coding interview practice page.
- Prepare behavioral stories. Our question bank of 10,000+ real interview questions includes behavioral and company-specific questions. If you are interviewing at Amazon, start with our Amazon interview questions and Amazon SDE interview preparation guides.
- Warm up on the day. A short warm-up helps. Our Google Interview Warmup review covers one free option, and our technical interview preparation guide has a fuller plan.
Interview Sidekick has a free tier with no credit card required. It is built for preparation: complete the Codility assessment itself on your own, following the rules in your test link.
Frequently Asked Questions
How long is a Codility test?
The employer sets the time limit. Codility says assessments typically last between half an hour and two hours. The limit is shown on the intro page before you start, and it covers the whole test, not each task.
Can I pause a Codility test?
No. You can open the link and read the instructions without starting, but once you press "Start" the timer cannot be paused or stopped. If you close the browser, your code is saved and you can return, but the clock keeps running.
Why did I score 0% on Codility when my code passed the example?
The example test case is not part of the actual scoring. Your submission is graded on hidden test cases that check edge cases and performance on large inputs, and code that does not compile earns no points. Passing the example only confirms that your code runs on one input.
Can I use Google or my own IDE during a Codility test?
It depends on the policy in your test link. Codility's rule is that you must work on your own without help from other people, and the testing organization decides whether other resources or an external IDE are allowed. If in doubt, ask the test administrator before you start.
Does Codility check for cheating?
Codility runs a similarity check that compares solutions against other submissions, solutions leaked online, and AI-generated solutions. Employers can also enable optional features such as photo ID verification, IP checks, camera recording, and screen sharing. If a test requires camera or screen access, you will be asked to grant it before you begin.
Which programming language should I use on Codility?
Use the language you are most comfortable in from the ones the employer allowed. Codility says the language you choose does not factor into your score unless the task is language-specific. Python is popular for its short syntax, but Java or C++ are fine if you are faster in them.
