Online Assessments · Strategy

How to Clear Online Coding Assessments on HackerRank, HackerEarth and Codility

Most candidates fail online assessments for reasons that have nothing to do with algorithms: misread constraints, slow I/O, overflow, wasted time and proctoring flags. Here is how to avoid all of them.

✍️ Pranjal Jain, Ex-Microsoft · IIT Kanpur 📅 10 October 2026 ⏱ 15 min read
Developer taking a timed online coding test with test-case results and a stopwatch
TL;DR
  • 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:

  1. You receive a link with a deadline window (often a few days). Once you start, a timer runs and usually can't be paused.
  2. You see the problem statement with an input/output format, constraints, and one or more sample tests.
  3. You write code in a browser editor. You can run it against the samples and usually against your own custom input.
  4. 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.
  5. 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

AspectHackerRankHackerEarthCodility
Problem formatFunction stub (fill in a function) or full stdin/stdout program, depending on the questionMostly full stdin/stdout programsUsually implement a function such as solution(A)
Running codeRun against samples and custom input; submit for hidden testsCompile and test with custom input; submit for hidden testsRun against example tests and your own test cases; final submission is evaluated on hidden tests
ScoringPer test case, often weightedPer test case, partial marking commonReport typically shows correctness and performance separately, combined into a task score
Other question typesMCQs, SQL, debugging, sometimes projectsMCQs, SQL, hackathon-style problemsMostly coding tasks; some SQL/other formats
Common in India forProduct companies, MNCs, many OAsHiring challenges, mass recruitment, startupsMNCs 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.

Java
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;
    }
}
Python
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 nTarget complexityTypical techniques
n ≤ 10–12O(n!) or O(n · 2ⁿ)Permutations, brute-force backtracking
n ≤ 20–25O(2ⁿ) or O(2ⁿ · n)Subsets, bitmask DP, meet-in-the-middle for ~40
n ≤ 500O(n³)Triple loops, Floyd–Warshall, interval DP
n ≤ 5,000O(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 moreO(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.

💡
Write the target complexity downBefore coding, write a comment like // 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.

C++
#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;
}
Python
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.setrecursionlimit knowing it can still hit stack limits. Use collections.deque for queues.
  • Java: Scanner is slow for large inputs; use BufferedReader with StringTokenizer. Watch Integer comparisons with == (compares references outside a small cached range); use .equals() or unbox. Our Java collections guide covers the other traps.
  • C++: int overflow, uninitialised variables, and endl in 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.

  1. Read every problem first (5 minutes total). Rank them by how confident you are, not by order.
  2. Fully solve the easiest problem first. A complete solution banks 100% of that problem's points and calms your nerves.
  3. 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.
  4. 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.
  5. Never leave a problem at zero if you have any correct approach, however slow.
  6. Resubmit often. Most platforms grade your last (or best) submission; submitting improvements as you go protects you if time runs out.
⚠️
Hard-coding is not partial creditPrinting the sample output or special-casing hidden inputs is easy to spot in code review and is treated as dishonest. Partial credit should come from a genuinely correct but slower algorithm.

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 caseExample bug it catches
Minimum size (n = 0 or 1)Accessing a[1], loops that assume a pair exists
All elements equalStrict vs non-strict comparisons, duplicate handling
All negative / zerosInitialising max to 0 instead of the first element
Sorted and reverse-sortedWorst-case behaviour, two-pointer termination
Maximum valuesInteger overflow in sums and products
Maximum nTimeouts from O(n²), recursion depth
No valid answerReturning 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:

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):

0–5 min

Read all problems

Note constraints and target complexity for each; rank by confidence.

5–25 min

Easy problem

Solve, test edge cases, submit. Move on even if it took a bit longer.

25–60 min

Medium problem

Plan for 5 minutes on paper, code, test, submit. Brute force first if stuck at 15 minutes.

60–85 min

Hard problem

Brute force for partial credit, then optimise. Submit after each improvement.

85–90 min

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.

SectionWhat's commonly askedHow to prepare
CS fundamentals MCQsOutput 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 queryJoins, GROUP BY with HAVING, subqueries, window functions such as ROW_NUMBER or RANKWrite queries on real tables; our SQL interview questions cover the standard set
AptitudeQuantitative (percentages, time-speed-distance, probability), logical reasoning, verbal abilityTimed sectional practice; see the aptitude preparation guide
Data structure MCQsComplexity of operations, tree traversals, heap properties, hashing collisionsMake 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.
🚫
Don't risk a disqualificationA plagiarism or proctoring flag can lead to disqualification and, at some companies, a long block from reapplying. No single OA is worth that. If something legitimately goes wrong (power cut, internet drop), email the recruiter immediately with details and screenshots; genuine technical issues are often accommodated.

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

  1. Uninterrupted block of the test length plus 20 minutes. Tell family or roommates.
  2. Stable internet, with a mobile hotspot as backup.
  3. Laptop charged and plugged in; notifications and auto-updates off.
  4. Updated browser as recommended by the platform; close other tabs and apps (especially chat apps that pop up).
  5. Webcam and microphone tested if proctoring is enabled; good lighting on your face.
  6. Practice test completed on the same platform to learn the editor.
  7. Template typed from memory once before starting, so it's fresh.
  8. 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.

WeekFocusWeekly routine
1MechanicsDaily: 2 problems on HackerRank/HackerEarth with stdin/stdout parsing. Memorise your I/O template. Do each platform's practice test.
2Core patterns under timeDaily: 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.
3Full simulations3 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

Do I get partial marks in HackerRank coding tests?▾
Usually yes. Most HackerRank, HackerEarth and Codility assessments score each problem by the number or weight of hidden test cases you pass. A correct but slow solution can earn the small-input cases, so submitting a working brute force is better than submitting nothing.
Can HackerRank detect copy-paste or tab switching?▾
Assessments can be configured to record events such as tab switches, copy-paste and window focus changes, and many also use webcam monitoring and plagiarism detection that compares code across candidates. What is enabled depends on the employer's settings. Assume you are being monitored and follow the instructions in the test.
Which language is best for online coding tests?▾
The one you are fastest and most accurate in. C++ and Java are safer when time limits are tight and inputs are large; Python is fastest to write but can be slower at runtime, so use efficient I/O and avoid heavy recursion. Check which languages the test allows before you start.
How is Codility different from HackerRank?▾
Codility tasks usually ask you to implement a function such as solution(A) instead of reading from standard input, and the final report typically scores correctness and performance separately. HackerRank tests use either function stubs or full standard input and output programs depending on the question. Both run hidden test cases after you submit.
What should I do if my solution passes sample tests but fails hidden ones?▾
Check edge cases first: empty or single-element input, all equal values, negative numbers, maximum constraints and integer overflow. Then check time complexity against the constraints. Writing a quick brute force and comparing outputs on random small inputs finds most logic bugs.
Can I use Google or an IDE during an online assessment?▾
Only if the test instructions explicitly allow it. Many assessments prohibit external resources, and some monitor tab switching. Using a local IDE may also be disallowed; if it is permitted, be careful when pasting code, as large pastes can be flagged.
How many problems do I need to solve to clear an online assessment?▾
Companies do not publish cutoffs, and they vary by role and applicant pool. As a rule of thumb, aim to fully solve the easier problems and earn as many test cases as possible on the hardest one. In competitive hiring, solving all problems fully may be necessary.

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 →
Pranjal Jain
Pranjal Jain

Ex-Microsoft SDE · IIT Kanpur · Founder of Prepflix. Helps engineers crack startup and product company interviews across India.