Why this set of 25 problems?

๐ŸŽฏ
From Real Hiring Loops
What fintech engineers actually ask
SouthBank India, Razorpay, and M-Pesa Kenya don't ask trick puzzles. They ask: Can you code a hash map lookup? Reverse a linked list? Do two-pointer? These 25 problems are the actual patterns. No fluff. Solve all of them, and you'll recognize 80% of the problems in a real interview loop.

Quick reference: When to use what

Structure Operation Time Space Use Case
list append, pop, access O(1) O(n) Ordered, frequency iteration
dict lookup, insert, delete O(1) avg O(n) Fast key-value, counting
set add, remove, check O(1) avg O(n) Dedup, membership test
tuple access, unpacking O(1) O(n) Immutable, hash keys
collections.deque append, popleft O(1) O(n) Queue, sliding window

Lists & Arrays (6 problems)

1. Two Sum
Easy
Given a list of integers and a target sum, return indices of two numbers that add up to the target. Each number used at most once.
solution.py
Time: O(n) | Space: O(n) for hash map
2. Move Zeroes
Easy
Move all zeroes to the end while maintaining relative order of non-zero elements. Do this in-place.
solution.py
Time: O(n) | Space: O(1)
3. Best Time to Buy and Sell Stock
Easy
Given price history, find max profit from a single buy-sell. You must buy before you sell.
solution.py
Time: O(n) | Space: O(1)
4. Container With Most Water
Medium
Two vertical lines form a container. Find two lines that together hold the most water. Water capacity = min(height[i], height[j]) ร— (j - i).
solution.py
Time: O(n) | Space: O(1)
5. Remove Duplicates from Sorted List (In-place)
Easy
Given a sorted list, remove duplicates in-place and return the new length. Modify the list so first k elements are unique.
solution.py
Time: O(n) | Space: O(1)
6. Rotate Array
Medium
Rotate a list to the right by k steps in-place. [1,2,3,4,5] rotated by 2 = [4,5,1,2,3].
solution.py
Time: O(n) | Space: O(1)

Hash Maps & Sets (5 problems)

7. Group Anagrams
Medium
Given a list of words, group anagrams together. Anagrams have the same letters in different order.
solution.py
Time: O(n * k log k) where k = word length | Space: O(n)
8. Top K Frequent Elements
Medium
Find the k most frequent elements. Return in any order.
solution.py
Time: O(n log k) | Space: O(n)
9. Longest Substring Without Repeating Characters
Medium
Find the length of the longest substring with no repeating characters. Use sliding window.
solution.py
Time: O(n) | Space: O(min(n, m)) where m = charset
10. Valid Anagram
Easy
Check if two strings are anagrams of each other.
solution.py
Time: O(n) | Space: O(1) with Counter (max 26 letters)
11. First Unique Character in a String
Easy
Find the index of the first character that appears only once. Return -1 if none.
solution.py
Time: O(n) | Space: O(1) (max 26 letters)

Stacks & Queues (4 problems)

12. Valid Parentheses
Easy
Check if a string with parentheses is valid. Each open bracket must close properly, in correct order.
solution.py
Time: O(n) | Space: O(n) for stack
13. Min Stack
Medium
Implement a stack that supports push, pop, top, and getMin() in O(1) time.
solution.py
Push/Pop/Top/getMin: All O(1) | Space: O(n)
14. Implement Queue using Stacks
Medium
Build a queue (FIFO) using two stacks (LIFO).
solution.py
Push: O(1) | Pop/Peek: O(1) amortized | Space: O(n)
15. Daily Temperatures
Medium
Given daily temperatures, for each day find how many days until a warmer day. Use a monotonic stack.
solution.py
Time: O(n) each element pushed/popped once | Space: O(n)

Linked Lists (3 problems)

16. Reverse Linked List
Easy
Reverse a linked list iteratively. Change pointers to reverse direction.
solution.py
Time: O(n) | Space: O(1)
17. Detect Cycle in Linked List (Floyd's Algorithm)
Easy
Detect if a linked list has a cycle. Use Floyd's tortoise & hare (two pointers).
solution.py
Time: O(n) | Space: O(1)
18. Merge Two Sorted Lists
Easy
Merge two sorted linked lists into one sorted list.
solution.py
Time: O(n + m) | Space: O(1)

Trees (3 problems)

19. Maximum Depth of Binary Tree
Easy
Find the maximum depth (height) of a binary tree. Depth = number of nodes on longest path from root to leaf.
solution.py
Time: O(n) | Space: O(h) recursive, O(w) BFS where h = height, w = width
20. Invert Binary Tree
Easy
Mirror a binary tree: swap left and right children recursively.
solution.py
Time: O(n) visit each node | Space: O(h)
21. Validate Binary Search Tree
Medium
Check if a binary tree is a valid BST. For each node: left subtree values < node < right subtree values.
solution.py
Time: O(n) | Space: O(h)

Two Pointers & Sliding Window (4 problems)

22. Three Sum
Medium
Find all unique triplets that sum to zero. No duplicates.
solution.py
Time: O(nยฒ) | Space: O(1) ignoring output
23. Longest Repeating Character Replacement
Medium
Replace at most k characters to make the longest repeating substring. Use sliding window.
solution.py
Time: O(n) | Space: O(1) (26 letters max)
24. Trapping Rain Water (Overview)
Hard
Calculate water trapped between elevation bars. Water at each position = min(max_left, max_right) - height[i].
solution.py
Time: O(n) | Space: O(1)
25. Minimum Window Substring (Overview)
Hard
Find the minimum window in s that contains all characters from t. Use sliding window + hash map.
solution.py
Time: O(n) | Space: O(m) where m = charset

Pattern recognition: When to reach for what

Choose your data structure

๐Ÿ”
Fast lookup? Counting frequency? โ†’ Use dict or Counter
๐Ÿ“
Need unique elements? Dedup? โ†’ Use set
โ†”๏ธ
Order matters? Two ends? โ†’ Use deque or list
๐Ÿ—๏ธ
LIFO (stack) or FIFO (queue)? โ†’ Use list.append() / list.pop() or deque
๐Ÿ”—
Pointer manipulation? Reversing? โ†’ Consider linked list or two-pointer technique

What patterns dominate at Indian & Kenyan fintechs?

SouthBank India (โ‚น transactions): Hash maps for fraud detection (fast lookup by account), two-pointer for reconciliation loops.

Razorpay (payments): Sliding windows for rate-limit checks, stacks for undo/redo, hash maps for idempotency keys.

M-Pesa Kenya (KSh transfers): Queues for transaction batching, deque for time-window rolling sums.

Safaricom, Twiga: Tree structures for regional hierarchies; two-pointer for list reconciliation.

All of them: Master hash maps, two-pointer, and sliding window. That's 60% of your interview.

Quick check: Do you know when to use what?

Question 1 / 5
What is the time complexity of looking up a key in a Python dict?
Question 2 / 5
You need to find the longest substring without repeating characters. What technique?
Question 3 / 5
Which data structure helps detect a cycle in a linked list with O(1) space?
Question 4 / 5
How do you implement a queue using stacks?
Question 5 / 5
For a sorted array, what's the fastest way to find two numbers that sum to a target?
0
/ 5
Perfect! Keep going

5 common interview follow-ups

Use two pointers from both ends, swap in O(n) time and O(1) space. Or use slicing nums[::-1] but that creates a copy. The pointer approach is what they want to see.
dict: when you need key โ†’ value mapping (e.g., char โ†’ count). set: when you only care about membership (e.g., "have I seen this?"). Both O(1) average lookup.
list: O(1) append, O(n) popleft (have to shift all). deque: O(1) append and popleft both. For queue operations, always use from collections import deque.
Use a min-heap of size k: push all elements, keep heap size โ‰ค k by popping the min. Final heap root is kth largest. O(n log k) time, O(k) space. Import heapq.nlargest(k, nums) in Python.
Python's sorted() is O(n log n) Timsort, guaranteed stable. Quicksort O(n log n) avg, O(nยฒ) worst. Mergesort O(n log n) always. For interviews, just say "I use Python's sort" unless they ask for a custom algorithm. Know when to avoid O(nยฒ) brute force.
Africa & India's Best AI Academy
๐Ÿค– AI-first ๐ŸŽ“ Placement Assistance

Live mock interviews with senior engineers

Join the Best AI Program: The AI-Era Analyst โ€” 5 months, fully online, with placement assistance. Week 1 is free.

Explore The AI-Era Analyst โ†’