Online Coding Test — free practice test
An online coding test is a remotely administered, automatically graded programming round, usually hosted on a platform such as HackerRank, Codility or HackerEarth. You solve one or more problems in a browser editor against hidden test cases within a time limit. It is the most common way companies screen developers at scale before scheduling interviews.
Updated 2026-06-19 · 8 marked questions on this page, no signup · 5 worked sample questions with answers · Timed role tests and certifications run inside the OnJob app.
Free practice test · no signup
Take the practice test now
8 multiple-choice questions in the style of a real online coding test, marked instantly on this page. Every answer comes with the working, so a wrong pick tells you which concept to revise. Nothing to install, no account, no email.
Q1. What is the worst-case time complexity of binary search on a sorted array of n elements?
Show the worked answer
Correct answer: O(log n). Each comparison discards half the remaining range, so the number of steps is the number of times n can be halved — log₂ n.
Q2. In the worst case, how many comparisons does binary search need on 1,000 sorted items?
Show the worked answer
Correct answer: 10. 2⁹ = 512 and 2¹⁰ = 1,024, so ten halvings are enough to cover 1,000 items. Nine would only guarantee 512.
Q3. A problem states n ≤ 1,000,000. Which solution is safe inside a typical time limit?
Show the worked answer
Correct answer: O(n log n). At n = 10⁶, O(n log n) is roughly 2×10⁷ operations. O(n²) is 10¹², which no judge will finish; the exponential and factorial options are far worse.
Q4. What is the sum of all integers from 1 to 100?
Show the worked answer
Correct answer: 5,050. The closed form is n(n+1)/2, so 100 × 101 ÷ 2 = 5,050. Knowing it lets you verify a loop’s output in O(1).
Q5. Kadane's algorithm solves which problem, and in what time?
Show the worked answer
Correct answer: Maximum contiguous subarray sum, in O(n). Kadane's keeps a running sum, resets it whenever it turns negative, and tracks the best sum seen — one pass, so O(n).
Q6. Which data structure gives average O(1) lookup by key?
Show the worked answer
Correct answer: Hash map. A hash map computes the slot directly from the key. A sorted array needs O(log n) via binary search, a linked list O(n), and a heap only gives O(1) access to its root.
Q7. What is the worst-case time complexity of quicksort?
Show the worked answer
Correct answer: O(n²). On an already-sorted input with a bad pivot choice, each partition removes only one element, giving n levels of O(n) work. The O(n log n) figure is the average case.
Q8. Which structure processes elements first-in, first-out?
Show the worked answer
Correct answer: Queue. A queue removes from the end it did not add to, so the oldest element leaves first. A stack is last-in, first-out.
Key takeaways
- An online coding test is a remotely administered, automatically graded programming round, usually hosted on a platform such as HackerRank, Codility or HackerEarth.
- A Online Coding Test typically covers: Problem solving, Language and IDE, Multiple-choice technical, Time management.
- You can take a 8-question practice test on this page — it marks itself instantly and shows the working for every answer, with no signup.
What an online coding test covers
Problem solving
Implementing correct, efficient solutions to algorithmic problems against hidden tests.
Language and IDE
Working comfortably in the platform's browser editor and your chosen language.
Multiple-choice technical
Many tests bundle MCQs on output prediction, complexity and core CS concepts.
Time management
Allocating minutes per problem and submitting partial solutions before the timer ends.
5 sample online coding test questions with answers
Genuinely-correct, worked examples. Try each one before opening the answer, then go back to the marked practice test above and sit it against the clock.
Q1. What is printed by a loop that sums integers from 1 to 100?
Answer: The sum of 1 to n is n(n+1)/2, so for n = 100 it is 100 × 101 ÷ 2 = 5050. Knowing the closed-form formula lets you verify a loop's output and solve the problem in O(1) instead of O(n).
Q2. Given an array, how do you find the maximum subarray sum?
Answer: Use Kadane's algorithm: track a running sum, resetting it to the current element whenever it goes negative, and keep the best sum seen. It finds the maximum contiguous subarray sum in a single O(n) pass.
Q3. How do you remove duplicates from an array of integers efficiently?
Answer: Insert every element into a hash set, which automatically discards duplicates, then read the set back out. This is O(n) time and O(n) space. If the array is sorted, you can instead do it in place with two pointers in O(1) extra space.
Q4. What is the difference between O(n) and O(n²) and why does it matter on large inputs?
Answer: O(n) grows in direct proportion to input size, while O(n²) grows with the square. For n = 1,000, that is 1,000 versus 1,000,000 operations — so an O(n²) solution can time out on the large hidden test cases that an O(n) one passes.
Q5. How would you count the number of vowels in a string?
Answer: Make a single pass over the string, and for each character check if it belongs to the set {a, e, i, o, u} (case-insensitive), incrementing a counter when it does. This is an O(n) one-pass solution.
How to prepare for an online coding test
- 01
Read every problem fully before coding any, then solve the easiest ones first to lock in guaranteed points.
- 02
Test your code against the sample cases the platform gives, plus your own edge cases, before submitting.
- 03
Watch the constraints: an input size up to a million signals you need an O(n) or O(n log n) solution, not O(n²).
- 04
Submit partial, working solutions — many platforms award points per passing test case, so never leave a problem blank.
- 05
Practise on the exact platform the company uses so the editor, custom-input box and submission flow feel familiar on test day.
Frequently asked questions
What is an online coding test?
Remote, auto-graded coding rounds run on platforms like HackerRank and Codility — what to expect and how to pass them. This page covers what it measures, 5 worked sample questions with answers, and 5 ways to prepare — then you can sit a timed role test or a free certification on OnJob.
What is printed by a loop that sums integers from 1 to 100?
The sum of 1 to n is n(n+1)/2, so for n = 100 it is 100 × 101 ÷ 2 = 5050. Knowing the closed-form formula lets you verify a loop's output and solve the problem in O(1) instead of O(n).
Given an array, how do you find the maximum subarray sum?
Use Kadane's algorithm: track a running sum, resetting it to the current element whenever it goes negative, and keep the best sum seen. It finds the maximum contiguous subarray sum in a single O(n) pass.
Can I take the test on this page, or do I have to sign up?
You can take it right here. The practice test above has 8 multiple-choice questions, marks itself the moment you press "Check my score", and shows the working for every answer. No account, no email and no download. Signing up is only needed for OnJob's timed role tests and certification tests.
Are these online coding test questions free to practise?
Yes. Every sample question and answer on this page is free to read. With a free OnJob account you can also take timed role tests and certification tests. Personalised AI role and skill tests are part of the paid plans.
Practise your online coding test under real conditions
The test above is self-marked and free. The next step is a timed role test on OnJob, with coding problems that run on a code runner, and then a free certification recruiters can verify.