Coding & technical

Online Coding 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 · 5 worked sample questions with answers · The interactive, scored tests run inside the OnJob app.

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.
  • This guide includes 5 worked sample questions with answers — then rehearse under timed, scored conditions in OnJob's free mock tests.
What it measures

What a 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.

Practice questions

5 sample online coding test questions with answers

Genuinely-correct, worked examples. Try each one before opening the answer, then practise the full set under timed, scored conditions on OnJob.

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.

Step by step

How to prepare for a online coding test

  1. 1

    Read every problem fully before coding any, then solve the easiest ones first to lock in guaranteed points.

  2. 2

    Test your code against the sample cases the platform gives, plus your own edge cases, before submitting.

  3. 3

    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²).

  4. 4

    Submit partial, working solutions — many platforms award points per passing test case, so never leave a problem blank.

  5. 5

    Practise on the exact platform the company uses so the editor, custom-input box and submission flow feel familiar on test day.

Free forever — no credit card

Practise your online coding test under real conditions

Reading worked answers is step one. Take a free, scored AI mock test on OnJob, see exactly where you stand, then apply to AI-matched jobs in one click.

Create my free profile — free