- Online assessments score you on hidden test cases. Read the constraints before anything else: they tell you the required complexity.
- Use a pre-practised I/O template (fast input in C++/Python) and know whether the platform wants a full program (stdin/stdout) or a function (Codility-style
solution(A)). - Partial credit is real: a correct brute force beats an unfinished optimal solution. Submit, then optimise.
- Most hidden-case failures are edge cases and overflow, not wrong algorithms. Test empty, single, duplicates, negatives and max values.
- Assume proctoring: webcam, tab-switch and copy-paste logging, plagiarism checks. Follow the rules in the instructions exactly.
Online assessments (OAs) are the first technical filter at almost every company that hires software engineers at scale in India, from mass recruiters to Amazon, Microsoft, fintechs and startups. They're usually 60–120 minutes, 2–4 coding problems, sometimes with MCQs, run on HackerRank, HackerEarth, Codility or a similar platform.
Plenty of candidates who can solve the problems still fail OAs. They lose time on input parsing, misjudge the complexity needed, overflow an int, or panic on the hard problem and leave the easy one half-done. This guide is about everything around the algorithm: platform mechanics, constraint reading, templates, scoring strategy, testing, time management and proctoring rules. The algorithms themselves are covered in our DSA patterns guide.
How Online Coding Assessments Work
The typical flow on every major platform:
- You receive a link with a deadline window (often a few days). Once you start, a timer runs and usually can't be paused.
- You see the problem statement with an input/output format, constraints, and one or more sample tests.
- You write code in a browser editor. You can run it against the samples and usually against your own custom input.
- You submit. Your code runs against hidden test cases: small ones for correctness and large ones for performance. Each case has a time limit and memory limit.
- The employer sees a report: score per problem, test cases passed, time taken, code, and any proctoring flags or plagiarism matches.
Two implications are easy to miss. First, samples are not the test; passing samples proves very little about the hidden cases. Second, the employer often sees your code and your activity log, not just your score, so clean code and clean conduct both matter.
HackerRank vs HackerEarth vs Codility: Platform Differences
| Aspect | HackerRank | HackerEarth | Codility |
|---|---|---|---|
| Problem format | Function stub (fill in a function) or full stdin/stdout program, depending on the question | Mostly full stdin/stdout programs | Usually implement a function such as solution(A) |
| Running code | Run against samples and custom input; submit for hidden tests | Compile and test with custom input; submit for hidden tests | Run against example tests and your own test cases; final submission is evaluated on hidden tests |
| Scoring | Per test case, often weighted | Per test case, partial marking common | Report typically shows correctness and performance separately, combined into a task score |
| Other question types | MCQs, SQL, debugging, sometimes projects | MCQs, SQL, hackathon-style problems | Mostly coding tasks; some SQL/other formats |
| Common in India for | Product companies, MNCs, many OAs | Hiring challenges, mass recruitment, startups | MNCs and global companies |
Features change and employers configure tests differently, so always read the instruction page before starting. Most platforms offer a sample or practice test; take it. Five minutes on the practice test saves you from discovering the editor's quirks under time pressure.
Function stubs vs full programs
With a function stub, the platform reads input and calls your function; you only return the answer. Don't print extra output, and don't read from stdin yourself. With a full program, you read input exactly as specified and print output exactly as specified. Extra spaces or debug prints can fail every test case. Remove or comment out debug output before submitting.
A Codility-style function example
Codility tasks typically look like this: given an array A, return the smallest positive integer that does not occur in it. You implement the function only.
import java.util.HashSet;
class Solution {
public int solution(int[] A) {
HashSet<Integer> seen = new HashSet<>();
for (int x : A) if (x > 0) seen.add(x);
int ans = 1;
while (seen.contains(ans)) ans++; // at most n + 1 iterations
return ans;
}
}
def solution(A):
seen = {x for x in A if x > 0}
ans = 1
while ans in seen:
ans += 1
return ans
O(n) time and space. Note how the performance tests would punish an O(n²) approach (for example, checking ans in A on a list each time), even though it passes every small example.
Reading Constraints: The Most Important Minute
Constraints tell you the intended complexity. A useful rule of thumb is that a C++ solution can do on the order of 10⁸ simple operations per second; Java is in the same ballpark, and Python is substantially slower, often by an order of magnitude or more for loop-heavy code. Time limits are typically 1–2 seconds for C++ (platforms often give other languages more).
| Max n | Target complexity | Typical techniques |
|---|---|---|
| n ≤ 10–12 | O(n!) or O(n · 2ⁿ) | Permutations, brute-force backtracking |
| n ≤ 20–25 | O(2ⁿ) or O(2ⁿ · n) | Subsets, bitmask DP, meet-in-the-middle for ~40 |
| n ≤ 500 | O(n³) | Triple loops, Floyd–Warshall, interval DP |
| n ≤ 5,000 | O(n²) | 2-D DP, nested loops over pairs |
| n ≤ 10⁵ – 10⁶ | O(n log n) or O(n) | Sorting, heaps, binary search, two pointers, hashing, prefix sums |
| n ≤ 10⁹ or more | O(log n) or O(1) | Binary search on answer, math formula, fast exponentiation |
Also read the value constraints. If values go up to 10⁹ and you sum up to 10⁵ of them, the total can reach 10¹⁴, which overflows a 32-bit int (max about 2.1 × 10⁹). Use long long in C++ or long in Java. Python integers don't overflow, which is one of its genuine advantages in OAs. For a refresher on analysing complexity, see time and space complexity explained.
// n ≤ 2e5 → need O(n log n); sums up to 2e14 → long long. It takes ten seconds and prevents the two most common hidden-test failures: timeouts and overflow.Fast I/O Templates for C++ and Python
For full-program problems, input handling is boilerplate you should never write from scratch under pressure. Practise one template per language until it's automatic. Here's a template that reads several test cases, each an array, and prints the maximum subarray sum (Kadane's algorithm) as a stand-in for your logic.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
ios::sync_with_stdio(false); // faster cin/cout
cin.tie(nullptr);
int t;
if (!(cin >> t)) return 0;
while (t--) {
int n;
cin >> n;
vector<ll> a(n);
for (auto &x : a) cin >> x;
ll best = a[0], cur = 0;
for (ll x : a) {
cur = max(x, cur + x);
best = max(best, cur);
}
cout << best << '\n'; // '\n', not endl (endl flushes every line)
}
return 0;
}
import sys
def main():
data = sys.stdin.buffer.read().split() # read everything at once
idx = 0
t = int(data[idx]); idx += 1
out = []
for _ in range(t):
n = int(data[idx]); idx += 1
a = list(map(int, data[idx:idx + n])); idx += n
best, cur = a[0], 0
for x in a:
cur = max(x, cur + x)
best = max(best, cur)
out.append(str(best))
sys.stdout.write("\n".join(out) + "\n") # one write at the end
main()
Input 2 / 5 / -2 1 -3 4 -1 / 3 / -5 -2 -9 (one token group per line) prints 4 and -2. The Python version reads all tokens at once, which makes it robust to inputs split across lines unexpectedly, and is much faster than calling input() in a loop for large inputs.
Language-specific traps
- Python: recursion depth defaults to about 1,000. Deep DFS on a 10⁵-node tree will crash. Prefer iterative DFS/BFS, or raise the limit with
sys.setrecursionlimitknowing it can still hit stack limits. Usecollections.dequefor queues. - Java:
Scanneris slow for large inputs; useBufferedReaderwithStringTokenizer. WatchIntegercomparisons with==(compares references outside a small cached range); use.equals()or unbox. Our Java collections guide covers the other traps. - C++:
intoverflow, uninitialised variables, andendlin tight loops. Know your STL; the C++ STL guide is a quick refresher.
Partial Score Strategy: Bank Points First
Because scoring is per test case, the OA is closer to an exam with partial marks than to a pass/fail interview. A few strategic rules follow from that.
- Read every problem first (5 minutes total). Rank them by how confident you are, not by order.
- Fully solve the easiest problem first. A complete solution banks 100% of that problem's points and calms your nerves.
- On a hard problem, submit a brute force early. If the optimal solution isn't clear within 10–15 minutes, write the simplest correct solution and submit it. It typically passes small cases. Then work on optimising.
- Handle special cases cheaply. If the full problem is hard but a special case (all values positive, n small) is easy, handling it separately can earn extra cases.
- Never leave a problem at zero if you have any correct approach, however slow.
- Resubmit often. Most platforms grade your last (or best) submission; submitting improvements as you go protects you if time runs out.
Testing and Stress-Testing Your Solution
"Passes samples, fails hidden tests" is the most common OA frustration. A systematic test list catches most of it.
The edge-case checklist
| Edge case | Example bug it catches |
|---|---|
| Minimum size (n = 0 or 1) | Accessing a[1], loops that assume a pair exists |
| All elements equal | Strict vs non-strict comparisons, duplicate handling |
| All negative / zeros | Initialising max to 0 instead of the first element |
| Sorted and reverse-sorted | Worst-case behaviour, two-pointer termination |
| Maximum values | Integer overflow in sums and products |
| Maximum n | Timeouts from O(n²), recursion depth |
| No valid answer | Returning garbage instead of -1 or the specified value |
Stress-testing with a brute force
When you have spare time and a doubt about correctness, write a brute force and compare it with your fast solution on many small random inputs. It's the single most effective way to find logic bugs, and it takes a few minutes in Python:
import random
def brute(a):
return max(sum(a[i:j + 1]) for i in range(len(a)) for j in range(i, len(a)))
def fast(a):
best, cur = a[0], 0
for x in a:
cur = max(x, cur + x)
best = max(best, cur)
return best
for trial in range(2000):
n = random.randint(1, 8)
a = [random.randint(-10, 10) for _ in range(n)]
if brute(a) != fast(a):
print("MISMATCH", a, brute(a), fast(a))
break
else:
print("all 2000 random tests passed")
Small sizes and small value ranges are deliberate: they make bugs likely to appear and easy to read when they do. If the platform lets you run custom code, you can do this in the editor; otherwise, do it as practice habit beforehand so you develop the instinct for which cases break which algorithms.
Time Management for a 90-Minute, 3-Problem OA
A concrete plan for a common format (three problems: easy, medium, hard):
Read all problems
Note constraints and target complexity for each; rank by confidence.
Easy problem
Solve, test edge cases, submit. Move on even if it took a bit longer.
Medium problem
Plan for 5 minutes on paper, code, test, submit. Brute force first if stuck at 15 minutes.
Hard problem
Brute force for partial credit, then optimise. Submit after each improvement.
Final pass
Remove debug prints, check overflow, resubmit if needed.
Two time rules: don't debug in silence for more than 10 minutes (switch problems and return fresh), and don't leave submitting to the last minute, because submissions can queue and the timer won't wait. For the problem-solving method itself, our guide on how to approach a DSA problem applies just as well to OAs.
MCQ, SQL and Aptitude Sections
Many OAs, especially for freshers and mass hiring, add non-coding sections. They're often separately timed and sometimes have negative marking, so read the instructions before the first question.
| Section | What's commonly asked | How to prepare |
|---|---|---|
| CS fundamentals MCQs | Output of code snippets (pointers, recursion, operator precedence), OS (scheduling, deadlocks, paging), DBMS (normal forms, keys, transactions), networking (OSI/TCP/IP layers, protocols) | Revise core subjects; practise "predict the output" questions in C/C++/Java |
| SQL query | Joins, GROUP BY with HAVING, subqueries, window functions such as ROW_NUMBER or RANK | Write queries on real tables; our SQL interview questions cover the standard set |
| Aptitude | Quantitative (percentages, time-speed-distance, probability), logical reasoning, verbal ability | Timed sectional practice; see the aptitude preparation guide |
| Data structure MCQs | Complexity of operations, tree traversals, heap properties, hashing collisions | Make a one-page complexity cheat sheet and revise it |
Two tactics: if there's negative marking, skip questions where you can't eliminate at least two options; if there isn't, never leave a question blank. And for "predict the output" questions, trace on paper rather than in your head, because they're designed around subtle details like integer division, pre- vs post-increment and short-circuit evaluation.
Proctoring Rules: What's Monitored and What Gets Flagged
Employers configure proctoring per test, so what's enabled varies. Assume any of these may be active:
- Webcam and screen monitoring, including snapshots or recordings, and checks for multiple faces or no face.
- Tab-switch and window-focus tracking: leaving the test tab is logged.
- Copy-paste tracking: large pastes into the editor are logged.
- Full-screen enforcement: exiting full screen may be logged or end the test.
- Plagiarism detection: your code is compared with other candidates' submissions and with known sources online. Code shared on Telegram groups for a running OA gets flagged.
- AI-assistance detection is increasingly discussed. Regardless of detection, using AI tools when the instructions prohibit external help is a violation, and you'll face the same problems live in interviews anyway.
What's usually allowed (check your instructions)
- Pen and paper for working out examples.
- Using the platform's own editor features and custom input.
- Language documentation, only if the instructions explicitly permit it.
Your Environment Checklist Before Starting
- Uninterrupted block of the test length plus 20 minutes. Tell family or roommates.
- Stable internet, with a mobile hotspot as backup.
- Laptop charged and plugged in; notifications and auto-updates off.
- Updated browser as recommended by the platform; close other tabs and apps (especially chat apps that pop up).
- Webcam and microphone tested if proctoring is enabled; good lighting on your face.
- Practice test completed on the same platform to learn the editor.
- Template typed from memory once before starting, so it's fresh.
- Water, paper and pen on the desk.
Also choose your timing: don't start a 90-minute OA at 1 am after a long day. Many invites give you a window of several days; use the slot when you're sharpest.
A Three-Week OA Practice Plan
OA performance improves fastest with timed practice in OA-like conditions, not with more untimed problem-solving.
| Week | Focus | Weekly routine |
|---|---|---|
| 1 | Mechanics | Daily: 2 problems on HackerRank/HackerEarth with stdin/stdout parsing. Memorise your I/O template. Do each platform's practice test. |
| 2 | Core patterns under time | Daily: 3 problems with a 25-minute cap each: arrays/hashing, two pointers, sliding window, binary search, heaps, BFS/DFS, basic DP. Log every failed hidden case and why. |
| 3 | Full simulations | 3 full mock OAs (e.g. 3 problems in 90 minutes, or a past contest), each followed by an hour of review. Practise the brute-force-first rule. |
Timed contests on LeetCode, Codeforces or CodeChef are excellent OA practice because they combine pressure, unseen problems and hidden tests. If you're preparing for a specific company, also read its OA guide; for example, our Amazon OA guide covers Amazon's work style and simulation sections that general practice won't prepare you for.
Keep an OA error log
After every practice OA, record each lost test case under one of these causes: wrong algorithm, wrong complexity (timeout), overflow, edge case, I/O format, or ran out of time. After three or four OAs, the log tells you exactly what to fix. Most people discover that a large share of their lost points come from the "boring" categories (overflow, edge cases, I/O), which are the cheapest to fix.
Clearing OAs is a learnable, mechanical skill layered on top of DSA knowledge. Read constraints first, use a practised template, bank partial credit, test edges, manage time deliberately and stay clean on proctoring, and your OA scores will reflect your real ability.
Frequently Asked Questions
Practise Under Real OA Conditions
Prepflix's DSA track includes timed, OA-style problem sets with hidden test cases, so the real assessment feels familiar.
Explore the Prepflix Course →