Coding & technical

Coding Assessment — free practice test

A coding assessment is a timed test where you solve programming problems by writing working code that passes hidden test cases. It evaluates your data-structures and algorithms knowledge, your ability to translate a problem into correct logic, and your code's efficiency. Most software-engineering hiring uses one as the first technical filter before live interviews.

Updated 2026-06-19 · 8 marked questions on this page, no signup · 5 worked sample questions with answers · AI-scored mock tests 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 coding assessment, 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. How much extra space does the two-pointer palindrome check need?
Show the worked answer

Correct answer: O(1). It stores two indices and compares characters in place, so the extra space does not grow with the string length.

Q2. Which technique detects a cycle in a singly linked list using O(1) extra space?
Show the worked answer

Correct answer: Floyd's tortoise-and-hare, with a slow and a fast pointer. The fast pointer moves two nodes per step and the slow one moves one; inside a cycle they must eventually meet. The hash-set method also works but costs O(n) space.

Q3. What is the time complexity of inserting into a balanced binary search tree with n nodes?
Show the worked answer

Correct answer: O(log n). A balanced tree has height proportional to log n, and insertion walks one root-to-leaf path.

Q4. Which traversal of a binary search tree visits the keys in ascending order?
Show the worked answer

Correct answer: In-order. In-order visits the left subtree, then the node, then the right subtree — and in a BST everything on the left is smaller and everything on the right is larger.

Q5. What is the cost of reading the element at a known index in an array?
Show the worked answer

Correct answer: O(1). Array elements sit in contiguous memory, so the address is computed arithmetically from the index — one step, whatever the size.

Q6. What is the worst-case time complexity of merge sort?
Show the worked answer

Correct answer: O(n log n). It splits the input log n times and does O(n) merging work at each level. Unlike quicksort, it has no bad-pivot case.

Q7. Two nested loops each run over the whole array of size n. What is the complexity?
Show the worked answer

Correct answer: O(n²). The inner loop runs n times for each of the n outer iterations, so the body executes n × n times.

Q8. What is the most efficient way to find the first non-repeating character in a string?
Show the worked answer

Correct answer: Count frequencies in a hash map, then rescan the string in order. Two linear passes — one to count, one to find the first character with a count of 1 — give O(n). The brute-force compare is O(n²) and sorting destroys the original order.

Key takeaways

  • A coding assessment is a timed test where you solve programming problems by writing working code that passes hidden test cases.
  • A Coding Assessment typically covers: Data structures, Algorithms, Complexity analysis, Debugging and edge cases.
  • 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 it measures

What a coding assessment covers

Data structures

Arrays, strings, hash maps, stacks, queues, linked lists, trees and graphs.

Algorithms

Sorting, searching, recursion, two-pointers, sliding window, greedy and dynamic programming.

Complexity analysis

Reasoning about the time and space complexity of your solution in Big-O terms.

Debugging and edge cases

Handling empty inputs, duplicates, overflow and boundary conditions so all test cases pass.

Practice questions

5 sample coding assessment 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. How would you check if a string is a palindrome in linear time?

Answer: Use two pointers, one at the start and one at the end. Compare the characters they point to; if any pair differs the string is not a palindrome. Move the pointers inward until they meet. This runs in O(n) time and O(1) extra space.

Q2. What is the time complexity of binary search and what does it require?

Answer: Binary search runs in O(log n) time by halving the search range each step. It requires the data to be sorted, because it compares the target to the middle element and discards half the range. On unsorted data you must sort first or use linear search.

Q3. How do you find the first non-repeating character in a string efficiently?

Answer: Make one pass to count each character's frequency in a hash map, then make a second pass and return the first character whose count is 1. This is O(n) time and O(1) extra space for a fixed alphabet, beating the O(n²) brute-force compare.

Q4. How would you detect a cycle in a linked list?

Answer: Use Floyd's tortoise-and-hare: advance a slow pointer one node and a fast pointer two nodes per step. If they ever meet, the list has a cycle; if the fast pointer reaches null, it does not. This uses O(n) time and O(1) space.

Q5. Reverse the order of words in a sentence — what is an efficient approach?

Answer: Split the sentence on spaces into an array of words, reverse the array, then join with single spaces. This is O(n) time. In place, you can reverse the whole string then reverse each word back to its original spelling.

Step by step

How to prepare for a coding assessment

  1. 1

    Build fluency in one language's standard library — its arrays, maps, sets and sorting — so you spend the clock on logic, not syntax.

  2. 2

    Learn the core patterns (two-pointers, sliding window, BFS/DFS, dynamic programming) because most problems are variations of them.

  3. 3

    Always clarify constraints first, then state your approach and its Big-O before you start coding.

  4. 4

    Run through edge cases — empty input, one element, duplicates, very large input — to catch the hidden test cases that fail naive solutions.

  5. 5

    Practise on a timer; in a real assessment, a correct O(n log n) solution submitted on time beats a perfect one left unfinished.

Frequently asked questions

Everything you need to know before you create your free profile.

Create My Free Profile

What is a coding assessment?

+

Timed programming challenges that test data structures, algorithms and problem-solving — the core technical screen for developer roles. This page covers what it measures, 5 worked sample questions with answers, and 5 ways to prepare — then you can sit a timed, scored version in OnJob's free AI mock tests.

How would you check if a string is a palindrome in linear time?

+

Use two pointers, one at the start and one at the end. Compare the characters they point to; if any pair differs the string is not a palindrome. Move the pointers inward until they meet. This runs in O(n) time and O(1) extra space.

What is the time complexity of binary search and what does it require?

+

Binary search runs in O(log n) time by halving the search range each step. It requires the data to be sorted, because it compares the target to the middle element and discards half the range. On unsorted data you must sort first or use linear search.

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 AI-scored mock tests, which grade written and spoken answers and can earn a verified skill badge.

Are these coding assessment questions free to practise?

+

Yes. Every sample question and answer on this page is free to read. OnJob's AI mock tests are free to start (₹0) — you get up to 3 mock tests and 1 real, badge-earning test every month, with instant scoring and feedback. Pro (₹99/month) adds more attempts and deeper analytics.

Free forever — no credit card

Practise your coding assessment under real conditions

The test above is self-marked and free. The next step is feedback: take a scored AI mock test on OnJob, see exactly where you stand against the role you want, then apply to AI-matched jobs in one click.