') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); })(); GitHub - DMJain/Notes: A comprehensive Executable Concept collection of System Design, HLD, LLD and DSA · GitHub
Skip to content

Repository files navigation

Notes - The Ultimate Revision Hub

A comprehensive collection of LeetCode solutions, Low-Level Design patterns, and System Design concepts

LeetCodeVisualizerLLDHLDResources


What's Inside

SectionDescriptionStatus
LeetCodeCurated problem solutions with detailed explanations✅ Active
VisualizerInteractive step-by-step algorithm visualizationNEW
LLD (Java)Object-Oriented Programming with Java examples✅ Active
LLD (Node.js)OOP concepts implemented in JavaScript✅ Active
LLD (Python)OOP patterns in Python✅ Active
HLDHigh-Level Design & System Design🔜 Coming Soon

LeetCode Solutions

Each problem includes: Question, Solution Code, and Detailed Explanation

Problems by Topic

Arrays & Hashing (click to expand)
#ProblemDescriptionQ-Card
1Two SumFind 2 nums that add to targetStore num→idx in map, check if complement exists
153SumFind triplets summing to 0Sort + fix one, two-pointer for rest, skip dupes
1200Minimum Absolute DifferenceFind pairs with min absolute differenceSort array → check adjacent differences
1752Check if Array Is Sorted and RotatedIs array a rotated sorted array?Count break points ≤ 1, check wrap-around
3719Longest Balanced Subarray ILongest subarray: distinct evens = distinct oddsO(n²) diff trick: +1 even, -1 odd, diff==0
Stack (click to expand)
#ProblemDescriptionQ-Card
20Valid ParenthesesCheck if brackets are validStack: push open, pop matching close
85Maximal RectangleLargest rect of 1s in matrixConvert to histogram per row, use monotonic stack
Strings & Substrings (click to expand)
#ProblemDescriptionQ-Card
3Longest Substring Without RepeatingMax substring with unique charsSliding window + set, shrink on duplicate
521Longest Uncommon Subsequence ILongest seq not in both stringsIf strings differ → longer one wins
522Longest Uncommon Subsequence IILongest seq not subseq of othersSort by len, check if subseq of any other
67Add BinarySum two binary stringsTwo pointers R→L, carry = t/2, digit = t%2
524Longest Word in DictionaryLongest dict word from deleting charsTwo-pointer subseq check, pick longest/smallest
3713Longest Balanced Substring ILongest substring: all chars same freqO(n²) uniq==cntMax: all chars at max freq?
3714Longest Balanced Substring IISame as 3713, n≤10⁵ needs O(n)Decompose 3 chars into 7 subsets, diff+HashMap
Binary Search (click to expand)
#ProblemDescriptionQ-Card
4Median of Two Sorted ArraysFind median of 2 sorted arraysBinary search on smaller array, partition both
3453Separate Squares IMin Y for equal area splitMonotonic area → Binary Search on Y
Dynamic Programming (click to expand)
#ProblemDescriptionQ-Card
10Regular Expression MatchingMatch string with . and *2D DP: * = zero or more of prev char
514Freedom TrailMin rotations to spell word on ringDP on (ring pos, key idx), try all char positions
799Champagne TowerHow full is glass (i,j) after pouring?Simulate top→bottom, cap at 1.0, split excess 50/50
1895Largest Magic SquareLargest k×k magic square in gridPrefix sums for rows/cols, check all squares
1937Max Points with CostMax points from grid with penaltyDP with left/right pass optimization
3651Min Cost Path with TeleportationsGrid path with k free teleports1D DP + Suffix Minimum for O(1) teleport
Sliding Window (click to expand)
#ProblemDescriptionQ-Card
992Subarrays with K DistinctCount subarrays with exactly K distinctatMost(K) - atMost(K-1) trick
995Min K Bit FlipsMin flips to make all 1sGreedy flip at each 0, track flips with queue
1423Max Points from CardsPick k cards from ends for max sumFind min window of (n-k), answer = total - min
1438Longest Subarray With LimitLongest subarray where max-min ≤ limit2 monotonic deques: maxq (dec), minq (inc)
1984Min Diff Between K ScoresMin diff in k consecutive elementsSort + sliding window of size k
Two Pointers (click to expand)
#ProblemDescriptionQ-Card
1877Minimize Max Pair SumMin the max pair sumSort, pair smallest with largest
1984Min Diff Between K ScoresMin diff in k consecutive elementsSort + sliding window of size k
Greedy (click to expand)
#ProblemDescriptionQ-Card
1007Min Domino RotationsEqual row by swapping top/botCheck tops[0] & bottoms[0] as targets
1877Minimize Max Pair SumMin the max pair sumSort, pair smallest with largest
2943Maximize Square Hole AreaMax square hole from removing barsSort bars, find max consecutive bars
2975Maximum Square AreaMax square from removing fencesAll gaps: HashSet(H-gaps) ∩ V-gaps
Backtracking (click to expand)
#ProblemDescriptionQ-Card
17Letter CombinationsAll letter combos from phone digitsBacktrack: choose→explore→unchoose for each digit
22Generate ParenthesesAll valid parenthesis combosBack track: open < n, close < open
401Binary WatchAll times with k LEDs onGosper's hack: iterate k-bit subsets of 10 LEDs
526Beautiful ArrangementCount permutations where i%perm[i]==0 or vice versaBacktrack, try each unused num at each pos
Trees & Graphs (click to expand)
#ProblemDescriptionQ-Card
110Balanced Binary TreeIs tree height-balanced?Bottom-up DFS, -1 sentinel for short-circuit
1382Balance a Binary Search TreeConvert unbalanced BST to balancedIn-order → sorted list → pick mid as root
865Smallest Subtree with Deepest NodesLCA of all deepest nodesDFS returns (depth, node), if L==R curr is LCA
2976Min Cost to Convert String IMin cost to convert string charsFloyd-Warshall on 26-node graph, O(26³+n)
2977Min Cost to Convert String IIMin cost for substring transformsTrie + Floyd-Warshall + DP, O(n×L + K³)
3650Min Cost Path with Edge ReversalsMin cost with optional edge reversalAdd reverse edges (2× cost), run Dijkstra
3651Min Cost Path with TeleportationsGrid path with k free teleports1D DP + Suffix Min by cell value
Linked Lists (click to expand)
#ProblemDescriptionQ-Card
23Merge K Sorted ListsMerge k sorted lists into oneD&C or MinHeap: O(N log k)
Math & Geometry (click to expand)
#ProblemDescriptionQ-Card
67Add BinarySum two binary stringsTwo pointers R→L, carry = t/2, digit = t%2
1266Min Time Visiting All PointsMin time to visit points (Chebyshev)Max(abs(dx), abs(dy)) as diag = 1 sec
3047Largest Square in Two RectsMax square in intersection of any pairCheck all N² pairs, intersect is [maxL, minR]
Matrix & Prefix Sum (click to expand)
#ProblemDescriptionQ-Card
1895Largest Magic SquareLargest k×k magic square in gridPrefix sums for rows/cols, check all squares
1292Max Side Length with Sum <= ThresholdMax square with sum <= KPrefix Sums + Binary Search maxLen
Design (click to expand)
#ProblemDescriptionQ-Card
535Encode Decode TinyURLURL shortener designCounter + Base62, dual HashMaps
Bit Manipulation (click to expand)
#ProblemDescriptionQ-Card
190Reverse BitsReverse 32-bit integer's bitsLoop: extract LSB of n, push into rev via shift+OR
401Binary WatchAll times with k LEDs onGosper's hack: enumerate all k-bit subsets of 10 bits
3314Construct Min Bitwise Array IFind min x where x OR (x+1) = nOdd: clear rightmost bit of trailing 1s
Sweep Line (click to expand)
#ProblemDescriptionQ-Card
3454Separate Squares IIMin Y for equal area (overlaps=union)Sweep line events (y, type), merge intervals

Problems by Number

Click to expand
#ProblemDifficultyQ-Card 💡
1Two Sum🟢 EasyMap lookup: target - num exists?
3Longest Substring Without Repeating🟡 MediumSlide window + set, shrink on dupe
4Median of Two Sorted Arrays🔴 HardBinary search smaller arr, partition both
10Regular Expression Matching🔴 Hard2D DP, handle * = 0 or more prev
153Sum🟡 MediumSort, fix 1, two-ptr rest, skip dupes
17Letter Combinations🟡 MediumBacktrack: choose→explore→unchoose
20Valid Parentheses🟢 EasyStack: push open, pop matching close
22Generate Parentheses🟡 MediumBacktrack: open < n, close < open
23Merge K Sorted Lists🔴 HardD&C or MinHeap: O(N log k)
67Add Binary🟢 EasyTwo pointers R→L, carry = t/2, digit = t%2
85Maximal Rectangle🔴 HardHistogram per row + Monotonic Stack
110Balanced Binary Tree🟢 EasyBottom-up DFS, -1 sentinel short-circuit
190Reverse Bits🟢 EasyExtract LSB → shift left → OR into rev, 32×
401Binary Watch🟢 EasyGosper's hack: k-bit subsets of 10 LEDs
514Freedom Trail🔴 HardDP(pos, idx), try all matching chars
521Longest Uncommon Subsequence I🟢 EasyDifferent strings? Longer wins
522Longest Uncommon Subsequence II🟡 MediumCheck each if subseq of any other
524Longest Word in Dictionary🟡 Medium2-ptr subseq check, longest/lex-smallest
526Beautiful Arrangement🟡 MediumBacktrack: try valid nums at each pos
535Encode Decode TinyURL🟡 MediumCounter + Base62, dual HashMaps
712Min ASCII Delete Sum🟡 MediumLCS variation: Total - 2*LCS_ASCII
744Find Smallest Letter Greater Than Target🟢 EasyBinary search for first letter > target
799Champagne Tower🟡 MediumSimulate pour: cap 1.0, overflow 50/50 down
865Smallest Subtree with Deepest Nodes🟡 MediumDFS return (depth, node), compare L/R depths
992Subarrays with K Distinct🔴 HardatMost(K) - atMost(K-1)
995Min K Bit Flips🔴 HardGreedy flip 0s, track with queue/diff
1007Min Domino Rotations🟡 MediumCheck tops[0] & bottoms[0] as targets
1200Minimum Absolute Difference🟢 EasySort + Single Pass to find min diff
1292Max Side Length with Sum <= Threshold🟡 MediumPrefix Sums + Binary Search maxLen
1266Min Time Visiting All Points🟢 EasyMax(abs(dx), abs(dy))
1382Balance a Binary Search Tree🟡 MediumIn-order + Divide & Conquer rebuild
1423Max Points from Cards🟡 MediumTotal - min window of (n-k)
1438Longest Subarray With Limit🟡 MediumMonotonic deques for max/min in window
1877Minimize Max Pair Sum🟡 MediumSort, pair smallest with largest
1895Largest Magic Square🟡 MediumPrefix sums for rows/cols, check all squares
1752Check if Array Is Sorted and Rotated🟢 EasyCount break points ≤ 1, check wrap-around
1937Max Points with Cost🟡 MediumDP with left/right pass optimization
1984Min Diff Between K Scores🟢 EasySort + sliding window of size k
2943Maximize Square Hole Area🟡 MediumSort bars, find max consecutive bars
2975Maximum Square Area🟡 MediumAll gaps: HashSet(H-gaps) ∩ V-gaps
3047Largest Square in Two Rects🟡 MediumCheck all N² pairs, intersect is [maxL, minR]
3314Construct Min Bitwise Array I🟢 EasyOdd: clear rightmost bit of trailing 1s
3453Separate Squares I🟡 MediumMonotonic area → Binary Search on Y
3454Separate Squares II🔴 HardSweep line (y-events) + Interval merging
3510Min Pair Removal to Sort Array II🔴 HardHeap + LinkedList for min pair sums
2976Min Cost to Convert String I🟡 MediumFloyd-Warshall on 26-node graph
2977Min Cost to Convert String II🔴 HardTrie + Floyd-Warshall + DP
3650Min Cost Path with Edge Reversals🟡 MediumAdd reverse edges (2×), run Dijkstra
3651Min Cost Path with Teleportations🔴 Hard1D DP + Suffix Min, k teleport layers
3713Longest Balanced Substring I🟡 MediumO(n²) uniq==cntMax: all chars at max freq?
3714Longest Balanced Substring II🟡 MediumDecompose 3 chars → 7 subsets, diff+HashMap
3719Longest Balanced Subarray I🟡 MediumO(n²) diff trick: distinct even-odd balance

Explanation Structure

Every problem follows a standardized explanation format:

  1. Problem in Simple Words - Easy to understand problem statement
  2. Brute Force Approach - With analysis of why it's suboptimal
  3. Intuitive/Greedy Approach - Examples where it works and fails
  4. Optimal Solution - With visualization and step-by-step walkthrough
  5. Complexity Analysis - Time & Space for all approaches
  6. Key Takeaways - Pattern recognition & what to remember

DSA Visualizer

Interactive step-by-step algorithm visualization - Reads directly from your LeetCode folder!

Single Source of Truth Architecture

LeetCode/ ← Your solutions (Question.md, Explanation.md, .java)
↓ API reads from
VisualizerBackend/ ← Express server (localhost:3001)
↓ Serves to
Visualizer/ ← React frontend (localhost:5173)

No duplicate content - Add questions to LeetCode folder, visualizer auto-detects them!

Features

FeatureDescription
🔗 Auto-SyncReads Question.md, Explanation.md, and Java code from LeetCode folder
🎬 Step AnimationNavigate through algorithm execution step-by-step
📊 Array VisualizationSliding window, pointers, deques
✏️ Monaco EditorFull code editor with syntax highlighting
⌨️ Keyboard Shortcuts Prev

Run the Visualizer

# Terminal 1: Backendcd VisualizerBackend && npm install && npm run dev
# Terminal 2: Frontendcd Visualizer && npm install && npm run dev

Then open http://localhost:5173/

Tech Stack

  • Frontend: React 18 + Vite + Tailwind CSS 4 + Monaco Editor
  • Backend: Express.js (reads LeetCode folder)
  • Pattern Detection: Auto-detects sliding-window, two-pointer, etc.

Low-Level Design (LLD)

Master Object-Oriented Programming with practical examples in 3 languages

OOP Fundamentals

The LLD section covers core OOP concepts with hands-on code examples:

ChapterTopicDescription
c0IntroductionWhat is OOP? History, Why Abstraction matters
c1Access Modifierspublic, private, protected, package-private
c2ConstructorsDefault, Parameterized, Copy Constructors
c3Inheritanceextends, super, IS-A relationship
c4PolymorphismMethod Overloading & Overriding
c5InterfacesContracts, Multiple Inheritance
c6Abstract ClassesPartial Implementation, When to use
c7CompositionHAS-A relationship, Aggregation vs Composition

Key OOP Principle

 ┌─────────────────────────┐
│ ABSTRACTION │
│ (The Principle) │
│ "Hide complexity, │
│ show essentials" │
└───────────┬─────────────┘
│
┌───────────────────┼───────────────────┐
│ │ │
▼ ▼ ▼
┌───────────────┐ ┌───────────────┐ ┌───────────────┐
│ ENCAPSULATION │ │ INHERITANCE │ │ POLYMORPHISM │
│ (Pillar 1) │ │ (Pillar 2) │ │ (Pillar 3) │
└───────────────┘ └───────────────┘ └───────────────┘

Multi-Language Support

LanguagePathStatus
JavaLLD/✅ Complete
🟨 JavaScript (Node.js)LLD NodeJs/✅ Complete
🐍 PythonLLD Python/✅ Complete

Each language implementation covers the same concepts with language-specific nuances and best practices.

Concurrency

ChapterTopicDescription
c1IntroductionProcesses, Threads, Parallelism vs Concurrency
c2Threads in JavaThread creation, Lifecycle, Runnable interface
c3ExecutorsThread pools, ExecutorService, Types of executors
c4CallablesCallable interface, Future, Exception handling
c5Synchronization ProblemRace conditions, Critical sections
c6Mutex LocksReentrantLock, Lock interface, tryLock
c7Synchronized KeywordMethod & block synchronization, Intrinsic locks
c8Atomic DatatypesAtomicInteger, AtomicReference, CAS operations
c9Volatile KeywordMemory visibility, Happens-before
c10Concurrent CollectionsConcurrentHashMap, CopyOnWriteArrayList
c11SemaphoresCounting semaphores, Resource limiting
c12Producer ConsumerBlockingQueue, Wait-notify pattern
c13DeadlocksDetection, Prevention, Resource ordering
c14Wait NotifyObject.wait(), notify(), notifyAll()

Java Advanced Concepts

ChapterTopicDescription
c1GenericsType parameters, Bounded types, Wildcards
c2LambdasFunctional interfaces, Lambda syntax, Method references
c3StreamsStream API, Operations, Collectors, Parallel streams
c4Collection FrameworkCollection hierarchy, Common interfaces
c5List InterfaceArrayList, LinkedList, Vector, Stack
c6Set InterfaceHashSet, LinkedHashSet, TreeSet
c7Queue InterfacePriorityQueue, Deque, ArrayDeque
c8Map InterfaceHashMap, LinkedHashMap, TreeMap
c9IteratorsIterator, ListIterator, fail-fast vs fail-safe
c10Custom Objectsequals(), hashCode(), Comparable, Comparator

High-Level Design (HLD)

System Design concepts, patterns, and case studies

Coming Soon

  • System Design Fundamentals

    • Scalability, Reliability, Availability
    • CAP Theorem
    • Load Balancing
    • Caching Strategies
  • Design Patterns

    • Singleton, Factory, Builder
    • Observer, Strategy, Decorator
  • System Design Case Studies

    • URL Shortener
    • Rate Limiter
    • Notification System
    • Chat Application

Resources

Curated collection of articles, books, blogs, and videos

Coming Soon

Books

To be added...

Articles & Blogs

To be added...

Video Resources

To be added...

Useful Links

To be added...


Getting Started

Prerequisites

# For Java projects
Java 17+ (recommended: Java 21)
Maven 3.8+
# For Node.js projects
Node.js 18+
# For Python projects
Python 3.10+

Running the Code

LeetCode (Java)

cd LeetCode
mvn compile
mvn exec:java -Dexec.mainClass="org.example.Main"

LLD Java

cd LLD
mvn compile
mvn exec:java -Dexec.mainClass="org.example.p1_oops.c0_introduction.Main"

LLD Node.js

cd"LLD NodeJs"
node p1_oops/c0_introduction/Main.js

LLD Python

cd"LLD Python"
python p1_oops/c0_introduction/main.py

Project Structure

Notes/
├── 📂 LeetCode/ # LeetCode solutions (Java)
│ └── src/main/java/org/example/
│ ├── Q0001_TwoSum/
│ │ ├── TwoSum.java # Solution
│ │ ├── Question.md # Problem statement
│ │ └── Explanation.md # Detailed explanation
│ └── ...
│
├── 📂 VisualizerBackend/ # Backend API (reads LeetCode folder)
│ └── server.js # Express server
│
├── 📂 Visualizer/ # Frontend (React)
│ └── src/
│ ├── components/ # UI components
│ ├── engine/ # Algorithm execution
│ └── hooks/ # React hooks
│
├── 📂 LLD/ # Low-Level Design (Java)
├── 📂 LLD NodeJs/ # Low-Level Design (JavaScript)
├── 📂 LLD Python/ # Low-Level Design (Python)
│
└── 📄 README.md # You are here!

Contributing

This is a personal learning repository. If you find any issues or have suggestions:

  1. Feel free to open an issue
  2. Suggestions for new problems/topics are welcome
  3. Found a bug in an explanation? Let me know!

Progress Tracker

LeetCode

  • Easy: 12 solved
  • Medium: 28 solved
  • Hard: 10 solved
  • Total: 50 problems

LLD

  • OOP Fundamentals (8 chapters)
  • Concurrency (14 chapters)
  • Java Advanced Concepts (10 chapters: Generics, Lambdas, Streams, Collections)
  • Design Patterns (Coming Soon)
  • SOLID Principles (Coming Soon)

HLD

  • System Design Basics (Coming Soon)
  • Case Studies (Coming Soon)

⭐ Star this repo if you find it helpful! ⭐

Made with 💻 and ☕

About

A comprehensive Executable Concept collection of System Design, HLD, LLD and DSA

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages