Stop 15 · Portfolio & Interview PrepTopics · 5/9

Coding Rounds on LeetCode & HackerRank

Part of the Python Roadmap

In short

For many campus placements and off-campus jobs in India, the first filter is a timed online test on HackerRank or a similar platform. Steady practice turns that scary first round into a routine one.

Many companies, including those hiring through campus placements, run online coding tests on platforms like HackerRank and LeetCode. Regular practice by topic builds the pattern recognition these timed rounds need.

The jaadu lifts a small dumbbell in a sunny neighbourhood gym, with a row of progressively heavier dumbbells lined up on the rack beside it.

Think of it like this

Training at the gym

Nobody lifts heavy on day one. You train by muscle group, a little every day, and slowly add weight. Coding practice works the same way: one pattern at a time, such as hash maps, two pointers or BFS, a few problems a day, easy before medium. After a few weeks the moves feel natural under pressure.

Watch it happen

Two common formats

HackerRank-style tests

  • Often read input from stdin and print output
  • Hidden test cases, including large ones
  • Common in campus and hiring screens

LeetCode-style problems

  • You fill in a method on a Solution class
  • Input arrives as function arguments
  • Widely used for interview practice

Practise both formats so neither surprises you. The thinking is the same, only the input and output wrapping changes.

The big ideas

What you need to know

Practise by pattern

Group problems by technique: hashing, two pointers, sliding window, stacks, BFS/DFS, binary search, simple DP.

Little and often

Two or three problems a day beats a weekend marathon. Revisit problems you failed a week later.

Practise under time

Online tests give a fixed time window for a few problems. Join contests or use a timer so finishing on time feels normal.

Fast input

For big inputs, read everything at once with sys.stdin.read() instead of many input() calls.

See it in code

Walk through the code

python
1# HackerRank style: read from stdin, print to stdout2import sys3 4def main() -> None:5    data = sys.stdin.read().split()6    n = int(data[0])7    nums = list(map(int, data[1:1 + n]))8    target = int(data[1 + n])9    seen: dict[int, int] = {}10    for i, x in enumerate(nums):11        if target - x in seen:12            print(seen[target - x], i)13            return14        seen[x] = i15    print(-1, -1)16 17if __name__ == "__main__":18    main()19 20# LeetCode style: fill in the method, no input parsing21class Solution:22    def twoSum(self, nums: list[int], target: int) -> list[int]:23        seen: dict[int, int] = {}24        for i, x in enumerate(nums):25            if target - x in seen:26                return [seen[target - x], i]27            seen[x] = i28        return []

1/4Read all input at once and split on whitespace. Fast and works for any line layout.

The same two sum problem in both formats.

Save yourself the pain

Common mistakes

Oops

Grinding hundreds of random problems without review.

Do this instead

Pick by topic, and after each problem write one line on the pattern used. Redo the ones you got wrong.

Oops

Only testing with the sample input.

Do this instead

Try empty input, one element, duplicates, negatives and the largest size. Hidden tests check these.

Oops

Looking at the solution after five minutes.

Do this instead

Struggle for 20 to 30 minutes first, then read a hint, then the solution, and re-solve it the next day.

Your mission

A four-week practice plan

~30 min

Quick check

Your HackerRank solution passes the sample but times out on hidden tests. What's the most likely cause?

Go deeper

  1. 1Practise by topic: arrays, hashing, two pointers, stacks, trees and DP.
  2. 2Re-solve problems you got wrong a week later without looking.
  3. 3Take a few timed mock contests to get used to the pressure.

Also part of these roadmaps

More topics at this stop

Stuck on this topic? Ask an Insider

Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.

Download
InsideEdge