Most software jobs, from local companies in Dhaka to Google, test programming with coding interviews. They follow a pattern, and like any exam, they reward preparation.
The stages
- Online assessment: 2 or 3 timed problems on a website such as HackerRank or Codility, judged by hidden tests, like this site's practice problems.
- Technical interviews: 45 to 60 minutes with an engineer, on a video call or at a whiteboard. You solve one or two problems while talking.
- Other rounds: system design for experienced roles, and a behavioural interview about how you work with people.
What the interviewer judges
Getting the right answer matters, but it is only part of the score:
- Problem solving: do you understand the problem, find an approach, improve it?
- Coding: is the code correct, clear and well organised?
- Communication: can the interviewer follow your thinking? Silence is the most common way strong students fail.
- Testing: do you check your own code, and find your own bugs?
Six steps for any problem
- Understand. Repeat the problem in your own words. Ask about the input: how big? Can it be empty? Negative numbers? Duplicates? Is it sorted?
- Examples. Work one small example by hand, and an edge case.
- Brute force. Say the simplest correct solution and its cost, even if it is slow. It shows you can solve the problem, and gives you something to improve.
- Optimize. Look for repeated work. Ask: would sorting help? A hash map? Two pointers? This course is a catalogue of those patterns.
- Code. Write clean code, with good names, and keep talking.
- Test. Run your example through the code by hand, then the edge cases. Fix bugs calmly; everyone writes them.
def has_duplicate_slow(nums):
for i in range(len(nums)): # O(n²): every pair
for j in range(i + 1, len(nums)):
if nums[i] == nums[j]:
return True
return False
def has_duplicate(nums):
seen = set() # O(n): remember what we have seen
for x in nums:
if x in seen:
return True
seen.add(x)
return False
nums = [4, 1, 7, 3, 1, 9]
print(has_duplicate_slow(nums), has_duplicate(nums))
print(has_duplicate([1, 2, 3]))"Does this list contain a duplicate?" Step 3 gives two loops comparing every pair: O(n²). Step 4 notices the repeated work (each number is compared with everything again and again) and remembers the numbers seen so far in a set: O(n). That one idea, trading memory for speed with a hash set or map, solves a large share of interview problems.
Complexity, out loud
Always state the time and space complexity of your solution, in big-O:
| Big-O | Name | n = 10⁶ takes about |
|---|---|---|
| O(1) | constant | instant |
| O(log n) | logarithmic | 20 steps |
| O(n) | linear | 10⁶ steps |
| O(n log n) | sorting | 2 × 10⁷ steps |
| O(n²) | quadratic | 10¹² steps: too slow |
A rough rule: about 10⁸ simple steps per second in C++, and 10⁷ in Python. The input size often hints at the expected complexity: n up to 10⁵ rules out O(n²).
Practise out loud. Solve problems while explaining every step to an empty room, a friend, or a rubber duck. It feels silly, and it is the most effective preparation there is.
Quick check
My notes
Write down what you want to remember from this lesson. Notes are saved on this device as you type, and appear on your dashboard.