Back to blog

Job Hunt Diary #1: What My Last HackerRank Test Really Asked

careerinterviewjob-huntalgorithmsseries
Job Hunt Diary #1: What My Last HackerRank Test Really Asked

Job hunting as a software developer these days is a strange mix of waiting, rejection emails, and online tests that arrive at 11 PM with a 90-minute timer.

This is the first entry of a small series, Job Hunt Diary, where I write down what the process actually looks like, not what the career advice videos say it looks like. Part 1 is about the most recent HackerRank test I took.

The surprise: it was not a pure "LeetCode grind" test. It was a wider sweep of what a working engineer touches.

What the test covered:

  • Data structures and algorithms (DSA)
  • Big O (time and space complexity)
  • Linux shell / bash scripting
  • Process and thread
  • API integration: handling response data and protecting our system from external dependencies

What I'll Talk About

✅ Why this mix of topics tells you what the company really wants
✅ DSA: the patterns that show up again and again
✅ Big O: the question hiding behind every coding task
✅ Bash: small scripts that parse logs under time pressure
✅ Process vs thread: the concept questions that trip people up
✅ API integration: the part that felt most like real work
✅ A practical prep plan, and what I would do differently


0. Reading the Test as a Signal

Look at the five topics again. They map neatly onto what a backend engineer does in a normal week:

Three questions, in other words:

  1. Can you think clearly about problems and their cost?
  2. Can you operate in a Linux environment without a GUI and without Google?
  3. Can you write code that talks to other systems and does not fall over when they misbehave?

If you only prepared for the first one, the test would have felt unfair. If you prepared for all three, it felt like a fair sample of the job. That alone changed how I prepare.


1. DSA: The Patterns, Not the Problems

You cannot memorize 500 problems. You can recognize about ten patterns. The problems in my test all fell into familiar buckets:

PatternTypical signal in the problemTool
Frequency counting"count", "duplicates", "most common"Hash map
Two sum / complement"find a pair that..."Hash map, one pass
Two pointerssorted array, "pair", "palindrome"Two indices
Sliding window"longest/shortest subarray with..."Window + counter
Stackbrackets, "next greater", undoStack
BFS / DFSgrid, graph, "shortest path"Queue / recursion
Sorting + scanintervals, "merge", "schedule"Sort first

Here is the kind of problem that appears in almost every online assessment, solved in one pass with a hash map:

def first_unique_char(s: str) -> int:
    """Return the index of the first non-repeating character, or -1."""
    counts: dict[str, int] = {}
    for ch in s:
        counts[ch] = counts.get(ch, 0) + 1
 
    for i, ch in enumerate(s):
        if counts[ch] == 1:
            return i
    return -1
 
 
assert first_unique_char("leetcode") == 0
assert first_unique_char("aabb") == -1

And the sliding window, which feels like magic the first time:

def longest_unique_substring(s: str) -> int:
    seen: dict[str, int] = {}   # char -> last index
    start = best = 0
    for end, ch in enumerate(s):
        if ch in seen and seen[ch] >= start:
            start = seen[ch] + 1    # shrink window past the duplicate
        seen[ch] = end
        best = max(best, end - start + 1)
    return best
 
 
assert longest_unique_substring("abcabcbb") == 3

What I learned:

  • Read the constraints first. n <= 10^5 means O(n²) will time out. n <= 20 means brute force is probably intended.
  • Write the brute force in your head, say why it is slow, then improve it. That is exactly the conversation an interviewer wants.
  • Edge cases are half the score: empty input, one element, all duplicates, negative numbers.

2. Big O: The Question Behind Every Question

Even in an auto-graded test, Big O decides whether you pass: the hidden test cases are large, and a slow solution gets "Time limit exceeded" on them.

In live interviews it is explicit: "What is the time and space complexity?" You should be able to answer in one sentence.

ComplexityNameFeels likeExample
O(1)ConstantDictionary lookupd[key]
O(log n)LogarithmicHalving each stepBinary search
O(n)LinearOne loopFrequency count
O(n log n)LinearithmicSortingsorted(items)
O(n²)QuadraticNested loopsCompare every pair
O(2ⁿ)ExponentialTry every subsetNaive recursion

Two habits that saved me:

1. Count the hidden costs. x in some_list is O(n), not O(1). String concatenation inside a loop can be O(n²). list.pop(0) is O(n). Slicing copies.

# Looks O(n), is O(n²): `in` on a list scans the whole list
def has_duplicate_slow(nums: list[int]) -> bool:
    seen: list[int] = []
    for n in nums:
        if n in seen:
            return True
        seen.append(n)
    return False
 
 
# Truly O(n): `in` on a set is O(1) on average
def has_duplicate_fast(nums: list[int]) -> bool:
    seen: set[int] = set()
    for n in nums:
        if n in seen:
            return True
        seen.add(n)
    return False

2. Always state space too. The hash map trick trades O(n) memory for time. Say it out loud: "O(n) time, O(n) space, I am trading memory for speed."

For a deeper walkthrough, see my post Big O Notation: Complexity Analysis.


3. Linux Shell and Bash: The Underrated Section

This was the part many candidates skipped in preparation, and the one where a small amount of practice pays off the most.

Typical task: "Given a web server access log, print the top 5 IP addresses by request count." A good answer is one pipeline:

awk '{print $1}' access.log | sort | uniq -c | sort -rn | head -5

Read it left to right, each stage does one thing:

Other tasks of the same family:

# Count lines containing ERROR
grep -c "ERROR" app.log
 
# Find all 5xx responses and show the URL (field 7 in common log format)
awk '$9 ~ /^5/ {print $7}' access.log | sort | uniq -c | sort -rn
 
# Find large files modified in the last day
find /var/log -type f -size +50M -mtime -1
 
# Replace a config value in every .env file
sed -i 's/DEBUG=true/DEBUG=false/' */.env

And one small script with proper safety flags, because "it works on my machine" is not enough:

#!/usr/bin/env bash
set -euo pipefail   # stop on error, unset var, or failed pipe
 
LOG_DIR="${1:?usage: $0 <log-dir>}"
 
for file in "$LOG_DIR"/*.log; do
  [[ -e "$file" ]] || continue            # no matches: skip the literal glob
  errors=$(grep -c "ERROR" "$file" || true)  # grep exits 1 when count is 0
  echo "$file: $errors errors"
done

What I learned:

  • Know grep, awk, sed, sort, uniq, cut, find, xargs, head/tail. That covers 90% of what a test asks.
  • Know exit codes ($?), pipes, redirects (>, >>, 2>&1), and quoting. Unquoted variables are the classic bug.
  • If you want a solid foundation, start with Why Learning Linux Matters.

4. Process vs Thread: Concept Questions That Trip People Up

These were short multiple-choice and written answers. They look easy and punish vague understanding.

The core difference in one table:

ProcessThread
MemoryOwn address spaceShares memory with sibling threads
Creation costHeavyLight
CommunicationIPC (pipes, sockets, shared memory)Direct, via shared variables
Crash impactIsolated, others surviveCan take down the whole process
Main riskOverheadRace conditions, deadlocks

Questions I would be ready for:

  • What is a race condition? Two threads read-modify-write shared state, and the result depends on timing.
  • What is a deadlock? Thread A holds lock 1 and waits for lock 2, thread B holds lock 2 and waits for lock 1. Fix: always acquire locks in the same order.
  • Why does Python have the GIL, and when do you use processes instead of threads? Threads for I/O-bound work (waiting on network), processes for CPU-bound work.
  • Concurrency vs parallelism? Concurrency is dealing with many things at once; parallelism is doing many things at once.

A tiny demonstration of the race condition, which is worth being able to write from memory:

import threading
 
counter = 0
lock = threading.Lock()
 
 
def increment_unsafe(n: int) -> None:
    global counter
    for _ in range(n):
        counter += 1          # read, add, write: not atomic
 
 
def increment_safe(n: int) -> None:
    global counter
    for _ in range(n):
        with lock:            # only one thread inside at a time
            counter += 1

For the full story, see Process vs Thread.


5. API Integration: Protect Your System From Everyone Else's

This was my favorite part, because it felt like real work. The task gave a fake third-party API and asked to fetch data, handle the response, and not let the external dependency break our system.

The key mindset: the network is unreliable and the other side is not under your control. Everything it returns is untrusted input.

The checklist I now apply everywhere

RiskProtection
API hangs foreverTimeout on every call (connect and read)
Temporary failure (5xx, network blip)Retry with exponential backoff and jitter
API is down for a long timeCircuit breaker: stop calling, fail fast, recover later
Rate limit (429)Respect Retry-After, throttle your own calls
Malformed or surprising dataValidate with a schema, never trust fields blindly
Huge result setsPagination, with a max page limit
Retried writes happen twiceIdempotency keys
One slow dependency starves everythingBulkheads: limit concurrency per dependency
Total outageFallback: cached data or a graceful error

A small, honest implementation

import random
import time
 
import requests
from pydantic import BaseModel, ValidationError
 
 
class Order(BaseModel):
    id: int
    amount: float
    status: str
 
 
RETRYABLE = {429, 500, 502, 503, 504}
 
 
def fetch_orders(url: str, max_attempts: int = 4) -> list[Order]:
    for attempt in range(1, max_attempts + 1):
        try:
            resp = requests.get(url, timeout=(2, 5))  # (connect, read)
        except (requests.ConnectionError, requests.Timeout):
            resp = None
 
        if resp is not None and resp.status_code == 200:
            return parse_orders(resp.json())
 
        if resp is not None and resp.status_code not in RETRYABLE:
            # 4xx like 400/404 will not fix itself: do not retry
            raise RuntimeError(f"Non-retryable error: {resp.status_code}")
 
        if attempt == max_attempts:
            break
 
        # exponential backoff with jitter: ~1s, ~2s, ~4s
        delay = (2 ** (attempt - 1)) + random.uniform(0, 0.5)
        if resp is not None and "Retry-After" in resp.headers:
            delay = float(resp.headers["Retry-After"])
        time.sleep(delay)
 
    raise RuntimeError("External API unavailable after retries")
 
 
def parse_orders(payload: object) -> list[Order]:
    items = payload.get("data", []) if isinstance(payload, dict) else []
    orders: list[Order] = []
    for item in items:
        try:
            orders.append(Order.model_validate(item))
        except ValidationError:
            # one bad record must not poison the whole batch
            continue    # in real code: log it and count it
    return orders

Three decisions in that snippet are worth calling out, because they are what graders and interviewers look for:

  1. Retry only what can succeed on retry. A 404 will still be a 404 in two seconds.
  2. Skip bad records, do not crash the batch. And log them, so you notice when the partner changes their format.
  3. Validate at the boundary. Convert untrusted JSON into typed objects once, then the rest of your code can trust the types.

If the failures continue, retries make things worse (you hammer an already struggling service). That is when a circuit breaker steps in:

For the async version of the same ideas (timeouts, bounded concurrency), see From RQ Workers to an Asyncio Engine.


6. A Practical Prep Plan

If I were starting again with two weeks:

DaysFocusOutput
1-5DSA patterns, 2-3 problems per patternA cheat sheet of patterns, in my own words
6Big O on everything I solvedComplexity noted beside each solution
7-8Bash: log-parsing one-liners10 pipelines I can type without looking
9-10Process, thread, concurrencyRace condition + deadlock demos from memory
11-12API client with timeout, retry, validationA reusable fetch_with_resilience()
13One full mock test under a 90-minute timerA list of what slowed me down
14RestSleep

Test-day habits that helped:

  • Read all questions first, then start with the one you are most sure about. Banked points reduce panic.
  • Write a correct slow solution before an optimal one that does not work.
  • Run your own edge cases before submitting. Sample tests are always friendlier than hidden ones.
  • If you are stuck for 15 minutes, move on and come back.

Summary and Key Takeaways

✅ Modern tests sample the whole job: problem solving, the server, and the integration layer
✅ Learn DSA as about ten patterns, not hundreds of problems
✅ Big O is always being graded, even when nobody asks
✅ A handful of shell tools (grep, awk, sed, sort, uniq, find) cover most scripting questions
✅ Know process vs thread well enough to explain races and deadlocks in plain words
✅ For API integration: timeout, retry with backoff, validate, circuit-break, and never trust external data

The job hunt is a numbers game and also a learning game. Each test shows you exactly where the gaps are, and that is useful even when the answer is "not this time".

Next in the series: Job Hunt Diary #2, what interviews feel like after the online test, and how to handle the silence in between.

📬 Subscribe to Newsletter

Get the latest blog posts delivered to your inbox every week. No spam, unsubscribe anytime.

We respect your privacy. Unsubscribe at any time.

💬 Comments

Sign in to leave a comment

We'll never post without your permission.