Advanced Algorithmic Problem Solving · HIT

Problem Collection · LeetCode and Interview Practice

Annotated Problem Collection

Technique-matched problems for each week of Advanced Algorithmic Problem Solving

Use: prepare before practice, solve during labs, and curate selected solutions into the technique portfolio Expectation: each submitted solution includes modelling, correctness reasoning, complexity analysis, and edge-case tests

How to use this collection

Each weekly set contains interview-style problems selected because they exercise the technique taught that week. Start with the first two problems for pattern recognition, then use the remaining problems for transfer, proof practice, and implementation discipline. The notes identify what to look for while solving.

Week 1: Modelling, Constraints, and Baselines

ProblemTechnique focusWhy it fits
Two Sumhashing and constraint-based improvementShows the move from quadratic search to a linear hash-table model.
Valid Anagramcounting invariantTurns a text problem into a frequency-vector equality check.
Merge Intervalssorting plus invariantRequires precise modelling of overlap and a clean loop invariant.
Container With Most Watertwo pointersGood interview example for explaining why one pointer can be discarded.

Week 2: Exhaustive Search, Backtracking, and Pruning

ProblemTechnique focusWhy it fits
Subsetsbinary choice recursionCanonical state-space tree with clear output-size complexity.
Permutationsvisited-set backtrackingHighlights recursion state, used elements, and factorial complexity.
Combination Sumpruned enumerationUses monotone choices to avoid duplicate combinations.
N-Queensconstraint propagationClassic pruning problem using columns and diagonal occupancy sets.

Week 3: Dynamic Programming I

ProblemTechnique focusWhy it fits
Climbing Stairsone-dimensional recurrenceMinimal example for state, base case, transition, and space compression.
House Robberchoice DPForces students to encode mutually exclusive local choices.
Unique Pathsgrid DPClean two-dimensional tabulation with combinatorial interpretation.
Coin Changeunbounded knapsackIntroduces unreachable states and minimization over transitions.

Week 4: Dynamic Programming II

ProblemTechnique focusWhy it fits
Longest Increasing SubsequenceDP and binary-search optimizationGood contrast between O(n squared) DP and O(n log n) patience sorting.
Longest Common Subsequencetwo-sequence DPCanonical table recurrence with reconstruction discussion.
Partition Equal Subset Sumpseudo-polynomial DPConnects subset-sum modelling to complexity and constraints.
Burst Balloonsinterval DPRequires choosing the final action in an interval, a useful advanced pattern.

Week 5: Greedy Algorithms

ProblemTechnique focusWhy it fits
Jump Gamegreedy reachabilityShort problem with a strong invariant about farthest reachable index.
Non-overlapping Intervalsinterval schedulingDirect practice for earliest-finish-time exchange reasoning.
Task Schedulergreedy countingShows how frequency constraints become a schedule-length formula.
Minimum Number of Arrows to Burst Balloonsinterval stabbingNice variant for proving why sorting by right endpoint works.

Week 6: Divide and Conquer and Answer Search

ProblemTechnique focusWhy it fits
Koko Eating Bananasbinary search on answerClassic monotone feasibility predicate with integer boundary care.
Search in Rotated Sorted Arraymodified binary searchForces invariant design when the sorted half changes by case.
Count of Smaller Numbers After Selfdivide and conquer countingMerge-sort counting problem that connects recursion to order statistics.
Median of Two Sorted Arrayspartition searchAdvanced interview problem for precise binary-search proof.

Week 7: Advanced Data Structures

ProblemTechnique focusWhy it fits
Range Sum Query: MutableFenwick tree or segment treeDirect match for point updates and range queries.
Sliding Window Maximummonotonic dequeShows how a deque maintains candidates and gives amortized O(n).
Daily Temperaturesmonotonic stackSimple and effective for next-greater-element reasoning.
Accounts Mergeunion-findModels equivalence classes and component extraction through DSU.

Week 8: Graph Modelling and Traversal

ProblemTechnique focusWhy it fits
Course Scheduledirected graph and topological orderTurns prerequisites into cycle detection and ordering.
Rotting Orangesmulti-source BFSGood grid problem for levels, time, and queue invariants.
Pacific Atlantic Water Flowreverse graph traversalShows how reversing the search direction simplifies reachability.
Word Ladderimplicit graph BFSInterview staple for modelling words as graph vertices without materializing all edges.

Week 9: Shortest Paths, MST, SCCs, and Flow Ideas

ProblemTechnique focusWhy it fits
Network Delay TimeDijkstraDirect weighted shortest-path application with adjacency-list design.
Cheapest Flights Within K Stopsbounded Bellman-FordIllustrates why a stop limit changes the shortest-path state.
Critical Connections in a Networkbridges and low-link valuesPrepares students for SCC-style DFS timestamps and structural graph analysis.
Min Cost to Connect All Pointsminimum spanning treeClean MST problem where Prim or Kruskal can be justified.

Week 10: String Algorithms and Hashing

ProblemTechnique focusWhy it fits
Implement Trieprefix treeDirect implementation of dictionary operations and prefix queries.
Find All Anagrams in a Stringsliding window countsConnects string matching to frequency invariants.
Repeated DNA Sequencesrolling hash and encodingCompact example for fixed-length string hashing.
Longest Duplicate Substringbinary search plus hashingCombines answer search, suffix intuition, and collision discussion.

Week 11: Optimization Patterns and Hardness Awareness

ProblemTechnique focusWhy it fits
Partition to K Equal Sum SubsetsNP-hard style search with pruningShows why exponential backtracking remains necessary under small constraints.
Sudoku Solverconstraint searchPractical exact search with strong pruning and constraint propagation.
Shortest Path Visiting All Nodesstate compression BFSUses exponential state space with polynomial graph traversal over states.
Word Ladder IIBFS plus path enumerationDemonstrates output-sensitive complexity and why all shortest paths can be large.

Week 12: Technical Interview Simulation

ProblemTechnique focusWhy it fits
LRU Cachehash map plus linked list designHigh-signal interview problem for data-structure design and invariants.
Merge k Sorted Listsheap and divide and conquerAllows multiple valid approaches and complexity comparison.
Serialize and Deserialize Binary Treetree traversal protocolTests representation choices, edge cases, and clear explanation.
Trapping Rain Watertwo pointers or monotonic stackGood simulation problem for explaining alternative approaches.

Week 13: Final Competition Practice

ProblemTechnique focusWhy it fits
The Skyline Problemsweep line and heapContest-style combination of events, ordering, and active-set maintenance.
Swim in Rising WaterDijkstra or binary search plus BFSGood final review problem with multiple defensible algorithmic routes.
Minimum Cost to Make at Least One Valid Path in a Grid0-1 BFSIntroduces a contest-grade shortest-path variant with binary edge costs.
Word Ladder IIgraph search and reconstructionUseful capstone for modelling, BFS levels, predecessor graphs, and output size.