S
Saurav Danej
90-Day AI/ML LinkedIn Content System
← All days
28
Day 28 of 90Career

DSA wrap — patterns, study plan, interview prep

POST 1 of 5 MorningCareerRecap

8 patterns that solve 80% of interview problems

After two weeks of DSA, here's the pattern map I keep coming back to. Eight patterns. They cover 80% of leetcode-medium problems and the vast majority of coding interviews.

One — hash map / set. O(1) lookups. Replace 'in list' with 'in set'. Two-sum, dedup, group-by, anagram detection. The single most common Big-O upgrade.

Two — two pointers. Slow/fast for cycles. Opposite ends for sorted-array problems. Same direction for sliding window.

Three — sliding window. The pattern for 'best subarray with constraint X'. Variable window with for-loop + inner while-loop is the standard shape.

Four — stack. Match-and-pop. Parentheses, expression parsing, undo/redo, monotonic stack for next-greater-element problems.

Five — BFS. Shortest path on unweighted graphs and grids. Level-order traversal of trees. The deque + seen set + while-loop template.

Six — DFS. Recursion or explicit stack. Tree traversals, connected components, backtracking.

Seven — binary search. Find an element in a sorted array. Search the answer space when feasibility is monotonic. Half-open template, while lo < hi, lo = mid+1 or hi = mid.

Eight — DP. Recursion + memoisation. State as one English sentence first. Top-down with lru_cache or bottom-up with loops.

Most leetcode mediums map to one (or two) of these patterns. The skill that makes interviews easier isn't memorising algorithms — it's recognising which pattern applies. Five minutes thinking about the pattern beats fifty minutes coding the wrong approach.

The further skill — knowing when patterns DON'T apply, and what does. Brute force, math reasoning, greedy, divide and conquer. The eight above are the bread and butter; the rest is the spice.
#DSA#Algorithms#Python#100DaysOfCode#CodingInterview#CodingInterview
POST 2 of 5 MiddayCareerDeep dive

The 20-problem study list

Twenty leetcode problems that, between them, cover the eight patterns from this morning. Solve all of them. Understand why each works. You'll be in the 90th percentile of coding-interview prep.

Problems 1-3 — hash map / set. Two-sum, valid anagram, group anagrams. The 'in set' upgrade in three different shapes.

Problems 4-6 — sliding window. Longest substring without repeats, minimum window substring, valid parentheses. The third uses a stack but lives in the same pattern family — 'process tokens left to right with a helper structure'.

Problems 7-9 — linked list. Reverse linked list, has cycle (Floyd's), merge two sorted lists. The pointer-manipulation triad.

Problems 10-12 — BFS / DFS. Number of islands (DFS or BFS on a grid), course schedule (topological sort), open-the-lock (BFS on state space).

Problems 13-15 — trees. Inorder traversal, lowest common ancestor, level order traversal. The traversal templates plus their applications.

Problems 16-17 — binary search. Standard binary search, find peak element. The 'search the answer' technique surfaces in capacity / scheduling problems too.

Problems 18-20 — DP. Climbing stairs (1D, easy), coin change (1D with optimisation), longest common subsequence (2D).

Pace yourself. Two problems a day, ten days. Three problems a day, seven days. Don't rush — understanding why each solution works is the skill, not just getting the right answer.

For each problem — solve, explain out loud as if to an interviewer, write the cleanest version after the explanation. The explaining-out-loud part is what reveals what you understand vs what you memorised.

After these 20, if you're prepping for senior-level interviews, knock out 30 more leetcode mediums to cement pattern recognition. The patterns repeat; the second 30 will go three times faster than the first 20.
#DSA#Algorithms#Python#100DaysOfCode#CodingInterview#Leetcode
POST 3 of 5 AfternoonDSACode

The DSA cheatsheet I keep open

Print this. Pin it next to your monitor. Reach for it during interviews and tense debugging sessions.

The complexity reference for Python's built-in structures and their operations. Knowing these by reflex, not by re-deriving, saves real time during interviews.

list — append O(1) amortised, index O(1), insert at position O(n), delete at position O(n), search by value O(n).

dict — get/set/in/delete O(1) average. Worst case O(n) under heavy collisions but Python's hash functions make this rare for built-in types.

set — in/add/remove/discard all O(1) average. Set operations (union, intersection, difference) are roughly O(min(|a|,|b|)).

From collections — deque (append/popleft both O(1)), Counter (subclass of dict for counting, .most_common(k) is O(n log k)).

From heapq — heappush, heappop, heappushpop, heapreplace all O(log n). nlargest(k, iter) and nsmallest(k, iter) are O(n log k).

From bisect — bisect_left, bisect_right both O(log n). insort is O(log n) for the search but O(n) for the insert (shifts).

General data structure complexities:

Balanced BST — most ops O(log n). Python's stdlib doesn't have one; use sortedcontainers.SortedList.

Linked list — insert/delete given pointer O(1). Search O(n).

Union-Find — nearly O(1) amortised per operation with path compression and union by rank.

Knowing these by reflex turns 'I think this is O(n)' into 'this is O(n) because dict is O(1) per op'. The confidence speeds up interview pace and avoids second-guessing.
#DSA#Algorithms#Python#100DaysOfCode#CodingInterview#Python
POST 4 of 5 EveningCareerTip

How I think during a coding interview

A coding interview is half algorithm, half communication. The interviewer is grading both. My five-step routine, refined across many interviews, both as candidate and as interviewer.

Step one — restate the problem in my own words. Confirm the inputs, outputs, and edge cases with the interviewer. 'So I'm given an array of integers and a target. I need to return the indices of two elements that sum to the target. Can the indices be the same? Are there negative numbers? Always exactly one pair, or could there be many?' This step alone catches misunderstandings before you waste time.

Step two — talk through brute force. State its complexity. DON'T code it yet. 'A naive approach is two nested loops checking all pairs. That's O(n²) time, O(1) space. Here's how it would look — [outline only].' This shows you understand the problem and the baseline.

Step three — propose an optimisation. Name the pattern. 'I think we can do better with a hash map. As we iterate, we check if the complement (target - x) is already in the map. If yes, we've found the pair. Otherwise, store x with its index. O(n) time, O(n) space. Trade memory for time.'

Step four — code it, narrating each line. 'I'll use a dict called seen, mapping value to index. Iterate with enumerate. For each x, compute need = target - x. Check if need is in seen — if yes, return seen[need] and i. Otherwise, store seen[x] = i.'

Step five — test on edge cases. Empty array? Single element? Negative numbers? Duplicates? Walk through them out loud.

The person who blurts code immediately usually backtracks. The person who frames the problem first ships cleaner solutions and signals stronger thinking. Always frame first.
#DSA#Algorithms#Python#100DaysOfCode#CodingInterview#CodingInterview
POST 5 of 5 NightCareerRecap

Week 4 done — DSA wrapped

End of week four. 28 days. 140 posts. We're 31% through the sprint.

DSA is done. From Big-O literacy on Day 15 to dynamic programming on Day 27, we covered the foundational vocabulary that makes ML interviews bearable, makes code reviews precise, and lets you read other people's code with sharper eyes.

The two weeks of DSA in eight patterns (today's morning post). Hash map, two pointers, sliding window, stack, BFS, DFS, binary search, DP. Most leetcode-medium problems map to one or two of these. Recognition is the skill; coding follows.

Twenty practice problems for the patterns (today's midday post). Two-sum to longest common subsequence. Three weeks of focused practice gets you to interview-ready.

The DSA cheatsheet (today's afternoon post) — Python's built-in complexities at your fingertips. Internalise so you don't re-derive during pressure.

The interview routine (today's evening tip) — restate, constraints, brute force, pattern + optimisation, code with narration. Half the interview is communication; treat it as such.

What we learned across the two weeks:

Big-O is a label, not math. Six classes cover almost everything.

Most data-structure choices come down to access pattern. Pick by what you'll do with the data.

Most algorithmic 'wins' come from picking the right tool — hash map over list scan, heap over full sort, BFS over generic graph search, DP over naive recursion.

Real Python perf bugs are usually I/O, not algorithm. Profile before you optimise.

Coming up. Next week, we leave DSA for the data stack — NumPy, Pandas, EDA, plotting. Practical Python for ML/data work. Then classical ML, deep learning, transformers, RAG, agents, automation, career.

Thank you for showing up these two weeks. See you in week 5.
#DSA#Algorithms#Python#100DaysOfCode#CodingInterview#90DaysOfAI