Skip to content

Shantanu1099/dsa-problems

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

109 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Core DSA Patterns for Interviews

A focused, pattern-based LeetCode preparation system for software engineering interviews.

Use this page as your Notion home base for DSA practice. Duplicate the trackers, update the status fields, and keep notes for patterns that you repeatedly miss.


Quick Dashboard

Area Target Status
Core Patterns 14 patterns Not Started
Must-Do Problems 75 problems Not Started
Revision Cycles 3 rounds Not Started
Mock Interviews 4 mocks Not Started
Weak Areas Update weekly Not Started

How to Use This System

  1. Start with one pattern at a time.
  2. Read the pattern playbook before solving problems.
  3. Solve 2 easy, 3 medium, and 1 hard problem per pattern where possible.
  4. For every problem, write the pattern, intuition, complexity, and mistake.
  5. Revisit missed problems after 2 days, 7 days, and 21 days.

5-Hour DSA Sprint Plan

Time Focus Output
0:00 - 0:20 Setup and diagnostic Pick target role, language, and weak areas
0:20 - 0:55 Arrays, Hashing, Two Pointers Solve 3 high-frequency problems
0:55 - 1:35 Sliding Window and Prefix Sum Learn when window vs prefix sum applies
1:35 - 2:10 Stack, Monotonic Stack, Intervals Practice pattern recognition
2:10 - 2:25 Break Review notes briefly
2:25 - 3:10 Binary Search and Heap Solve decision-space and top-k problems
3:10 - 4:00 Trees and Graphs Practice DFS, BFS, and visited-state logic
4:00 - 4:40 Dynamic Programming Identify state, transition, base case
4:40 - 5:00 Review and next steps Build 7-day practice plan

Core Pattern Roadmap

Order Pattern When to Use Confidence
1 Arrays and Hashing Counting, lookup, duplicates, frequency Low
2 Two Pointers Sorted arrays, pairs, reversing, shrinking range Low
3 Sliding Window Contiguous subarray or substring optimization Low
4 Prefix Sum Range sum, subarray count, cumulative state Low
5 Stack Matching, undo, nested structures, parsing Low
6 Monotonic Stack Next greater/smaller, temperature, histogram Low
7 Binary Search Sorted data or answer-space optimization Low
8 Linked List Pointer manipulation, cycle, reversal Low
9 Trees DFS/BFS, recursion, path, depth, LCA Low
10 Heap / Priority Queue Top K, streaming, scheduling, min/max retrieval Low
11 Backtracking Generate combinations, subsets, permutations Low
12 Graphs Connected components, shortest path, dependency order Low
13 Greedy Local choice leads to global optimum Low
14 Dynamic Programming Overlapping subproblems and optimal substructure Low

Problem Tracker

Status Problem Pattern Difficulty Link Notes
Not Started Two Sum Arrays and Hashing Easy https://leetcode.com/problems/two-sum/
Not Started Contains Duplicate Arrays and Hashing Easy https://leetcode.com/problems/contains-duplicate/
Not Started Valid Anagram Arrays and Hashing Easy https://leetcode.com/problems/valid-anagram/
Not Started Group Anagrams Arrays and Hashing Medium https://leetcode.com/problems/group-anagrams/
Not Started Product of Array Except Self Arrays and Hashing Medium https://leetcode.com/problems/product-of-array-except-self/
Not Started Valid Palindrome Two Pointers Easy https://leetcode.com/problems/valid-palindrome/
Not Started 3Sum Two Pointers Medium https://leetcode.com/problems/3sum/
Not Started Container With Most Water Two Pointers Medium https://leetcode.com/problems/container-with-most-water/
Not Started Best Time to Buy and Sell Stock Sliding Window Easy https://leetcode.com/problems/best-time-to-buy-and-sell-stock/
Not Started Longest Substring Without Repeating Characters Sliding Window Medium https://leetcode.com/problems/longest-substring-without-repeating-characters/
Not Started Minimum Window Substring Sliding Window Hard https://leetcode.com/problems/minimum-window-substring/
Not Started Subarray Sum Equals K Prefix Sum Medium https://leetcode.com/problems/subarray-sum-equals-k/
Not Started Range Sum Query Immutable Prefix Sum Easy https://leetcode.com/problems/range-sum-query-immutable/
Not Started Valid Parentheses Stack Easy https://leetcode.com/problems/valid-parentheses/
Not Started Min Stack Stack Medium https://leetcode.com/problems/min-stack/
Not Started Daily Temperatures Monotonic Stack Medium https://leetcode.com/problems/daily-temperatures/
Not Started Largest Rectangle in Histogram Monotonic Stack Hard https://leetcode.com/problems/largest-rectangle-in-histogram/
Not Started Binary Search Binary Search Easy https://leetcode.com/problems/binary-search/
Not Started Search in Rotated Sorted Array Binary Search Medium https://leetcode.com/problems/search-in-rotated-sorted-array/
Not Started Koko Eating Bananas Binary Search Medium https://leetcode.com/problems/koko-eating-bananas/
Not Started Reverse Linked List Linked List Easy https://leetcode.com/problems/reverse-linked-list/
Not Started Linked List Cycle Linked List Easy https://leetcode.com/problems/linked-list-cycle/
Not Started Merge Two Sorted Lists Linked List Easy https://leetcode.com/problems/merge-two-sorted-lists/
Not Started Binary Tree Inorder Traversal Trees Easy https://leetcode.com/problems/binary-tree-inorder-traversal/
Not Started Maximum Depth of Binary Tree Trees Easy https://leetcode.com/problems/maximum-depth-of-binary-tree/
Not Started Binary Tree Level Order Traversal Trees Medium https://leetcode.com/problems/binary-tree-level-order-traversal/
Not Started Lowest Common Ancestor of a Binary Tree Trees Medium https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree/
Not Started Kth Largest Element in an Array Heap / Priority Queue Medium https://leetcode.com/problems/kth-largest-element-in-an-array/
Not Started Top K Frequent Elements Heap / Priority Queue Medium https://leetcode.com/problems/top-k-frequent-elements/
Not Started Find Median from Data Stream Heap / Priority Queue Hard https://leetcode.com/problems/find-median-from-data-stream/
Not Started Subsets Backtracking Medium https://leetcode.com/problems/subsets/
Not Started Combination Sum Backtracking Medium https://leetcode.com/problems/combination-sum/
Not Started Word Search Backtracking Medium https://leetcode.com/problems/word-search/
Not Started Number of Islands Graphs Medium https://leetcode.com/problems/number-of-islands/
Not Started Clone Graph Graphs Medium https://leetcode.com/problems/clone-graph/
Not Started Course Schedule Graphs Medium https://leetcode.com/problems/course-schedule/
Not Started Meeting Rooms II Greedy / Heap Medium https://leetcode.com/problems/meeting-rooms-ii/
Not Started Merge Intervals Greedy / Intervals Medium https://leetcode.com/problems/merge-intervals/
Not Started Jump Game Greedy Medium https://leetcode.com/problems/jump-game/
Not Started Climbing Stairs Dynamic Programming Easy https://leetcode.com/problems/climbing-stairs/
Not Started House Robber Dynamic Programming Medium https://leetcode.com/problems/house-robber/
Not Started Coin Change Dynamic Programming Medium https://leetcode.com/problems/coin-change/
Not Started Longest Increasing Subsequence Dynamic Programming Medium https://leetcode.com/problems/longest-increasing-subsequence/
Not Started Edit Distance Dynamic Programming Hard https://leetcode.com/problems/edit-distance/

Pattern Playbooks

Arrays and Hashing

Core idea: Use direct indexing, maps, sets, or frequency counters to turn repeated lookup into constant-time operations.

Common signals:

  • Need to detect duplicates
  • Need pair lookup
  • Need counts or grouping
  • Need frequency comparison

Template questions:

  • What information do I need to remember while scanning?
  • Can a set or map avoid a nested loop?
  • Is order important, or only frequency?

Mistakes to watch:

  • Forgetting negative numbers
  • Confusing index with value
  • Sorting when hashing is enough

Two Pointers

Core idea: Use two indexes to move through a structure from both ends or at different speeds.

Common signals:

  • Sorted input
  • Pair or triplet target
  • Palindrome validation
  • In-place reversal

Template questions:

  • What condition moves the left pointer?
  • What condition moves the right pointer?
  • Does sorting change the problem meaning?

Mistakes to watch:

  • Infinite loops
  • Moving both pointers too early
  • Missing duplicate handling in 3Sum-style problems

Sliding Window

Core idea: Maintain a valid contiguous window and expand or shrink based on constraints.

Common signals:

  • Longest or shortest substring/subarray
  • Contiguous sequence
  • "At most", "at least", or "exactly" constraints

Template questions:

  • What makes the window valid?
  • When should I shrink?
  • What should be updated before and after shrinking?

Mistakes to watch:

  • Updating answer at the wrong time
  • Not removing left-side state
  • Treating non-contiguous problems as sliding window

Prefix Sum

Core idea: Convert repeated range calculations into cumulative sums.

Common signals:

  • Range sum queries
  • Subarray sum equals target
  • Need count of previous cumulative states

Template questions:

  • What does prefix[i] represent?
  • Do I need sum, count, or earliest index?
  • Is there a hashmap relationship like current_sum - target?

Mistakes to watch:

  • Missing initial prefix value 0
  • Off-by-one range boundaries
  • Using sliding window when negative numbers exist

Stack

Core idea: Track last-opened or last-seen items when the most recent unresolved item matters.

Common signals:

  • Parentheses or matching pairs
  • Nested expressions
  • Undo-like logic
  • Previous unresolved element

Template questions:

  • What should remain on the stack?
  • When do I pop?
  • What invariant does the stack maintain?

Mistakes to watch:

  • Not checking empty stack before popping
  • Storing value when index is needed
  • Losing required state during pop

Monotonic Stack

Core idea: Keep a stack in increasing or decreasing order to resolve next greater/smaller relationships.

Common signals:

  • Next greater element
  • Next smaller element
  • Span problems
  • Histogram area

Template questions:

  • Should the stack be increasing or decreasing?
  • Do I resolve when current is greater or smaller?
  • Do I need indexes for distance or width?

Mistakes to watch:

  • Choosing the wrong monotonic direction
  • Forgetting final cleanup pass
  • Storing values when duplicate values require indexes

Binary Search

Core idea: Repeatedly discard half the search space using a monotonic condition.

Common signals:

  • Sorted input
  • Search minimum feasible answer
  • Search maximum valid answer
  • "Can we do this within X?"

Template questions:

  • What is monotonic?
  • Am I finding exact value, first true, or last true?
  • How do I prove left/right updates?

Mistakes to watch:

  • Wrong loop condition
  • Infinite loop with mid calculation
  • Not validating answer-space boundaries

Linked List

Core idea: Use pointer manipulation carefully, often with dummy nodes or fast/slow pointers.

Common signals:

  • Reverse nodes
  • Detect cycle
  • Merge lists
  • Remove nth node

Template questions:

  • Do I need a dummy node?
  • What pointers must be saved before reassignment?
  • Can fast/slow pointers simplify the problem?

Mistakes to watch:

  • Losing the next pointer
  • Null pointer access
  • Not handling one-node lists

Trees

Core idea: Use recursion or BFS to process hierarchical structure.

Common signals:

  • Depth, path, ancestor, subtree
  • Level order traversal
  • Validate BST
  • Tree construction

Template questions:

  • Is this naturally DFS or BFS?
  • What should the recursive call return?
  • What is the base case?

Mistakes to watch:

  • Confusing node value with subtree result
  • Missing null base case
  • Global variable state leaking across calls

Heap / Priority Queue

Core idea: Efficiently retrieve the smallest or largest item as data changes.

Common signals:

  • Top K
  • Kth largest or smallest
  • Merge sorted streams
  • Scheduling by priority

Template questions:

  • Do I need min heap or max heap?
  • Should heap size stay fixed at K?
  • Is sorting simpler and acceptable?

Mistakes to watch:

  • Keeping all elements when only K are needed
  • Wrong heap direction
  • Forgetting that Python has a min heap by default

Backtracking

Core idea: Explore choices, undo choices, and prune invalid paths.

Common signals:

  • Generate all combinations
  • Generate all permutations
  • Search board/path
  • Need all valid possibilities

Template questions:

  • What is the current choice?
  • When is a path complete?
  • What state must be undone?

Mistakes to watch:

  • Forgetting to backtrack state
  • Duplicates in permutations/combinations
  • Missing pruning opportunities

Graphs

Core idea: Model relationships as nodes and edges, then traverse with DFS, BFS, Union Find, or topological sort.

Common signals:

  • Connected components
  • Shortest path in unweighted graph
  • Dependencies or prerequisites
  • Islands, grids, networks

Template questions:

  • What are the nodes?
  • What are the edges?
  • Do I need visited, distance, parent, or indegree?

Mistakes to watch:

  • Marking visited too late
  • Reprocessing nodes
  • Missing grid boundaries

Greedy

Core idea: Make the locally best choice when it can be proven to preserve global optimality.

Common signals:

  • Intervals
  • Scheduling
  • Minimum jumps
  • Buy/sell decisions

Template questions:

  • What choice is always safe?
  • What should be sorted?
  • Can I prove this choice never blocks a better answer?

Mistakes to watch:

  • Greedy without proof
  • Sorting by the wrong field
  • Missing tie handling

Dynamic Programming

Core idea: Solve repeated subproblems by defining state, transition, base cases, and answer.

Common signals:

  • Count ways
  • Min/max cost
  • Choose or skip
  • Longest/shortest sequence
  • Overlapping subproblems

Template questions:

  • What does dp[i] mean?
  • What previous states does dp[i] depend on?
  • What is the base case?
  • Can space be optimized?

Mistakes to watch:

  • Vague state definition
  • Wrong iteration order
  • Forgetting impossible states

Problem Review Template

Problem

Name:

Link:

Pattern:

Difficulty:

Date solved:

Status: Not Started / Solved With Help / Solved Alone / Needs Revision

Intuition

Write the plain-English idea here.

Approach

Complexity

Time: O()

Space: O()

Mistake Log

What I Should Remember


Weekly Review

Week Problems Solved Patterns Covered Weakest Pattern Action for Next Week
Week 1 0
Week 2 0
Week 3 0
Week 4 0

7-Day Starter Plan

Day Focus Problems
Day 1 Arrays, Hashing Two Sum, Contains Duplicate, Group Anagrams
Day 2 Two Pointers, Sliding Window Valid Palindrome, 3Sum, Longest Substring Without Repeating Characters
Day 3 Prefix Sum, Stack Subarray Sum Equals K, Valid Parentheses, Min Stack
Day 4 Binary Search, Linked List Binary Search, Search in Rotated Sorted Array, Reverse Linked List
Day 5 Trees Maximum Depth, Level Order Traversal, LCA
Day 6 Graphs, Heap Number of Islands, Course Schedule, Top K Frequent Elements
Day 7 DP and Review Climbing Stairs, House Robber, Coin Change, revise mistakes

Interview Readiness Checklist

  • I can explain Big O clearly.
  • I can identify the pattern before coding.
  • I can write clean code without relying on autocomplete.
  • I can test edge cases aloud.
  • I can explain tradeoffs between brute force and optimized solutions.
  • I have revised missed problems at least twice.
  • I have completed at least 2 mock interviews.

Mock Interview Notes

Date Interviewer Problem Pattern Result Feedback

Weak Area Log

Pattern Issue Fix Next Revision Date

About

This repo. contains solutions for problems using ds and algo.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages