Skip to content

riju-talk/DSA

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📚 DSA — Data Structures & Algorithms

Notes, code, patterns, and practice paths for interviews and mastery.

Stars Issues License C++ Python Java LeetCode CI Ready


🧭 Table of Contents


🎯 Why this repo

This repository is a single place to learn, revise, and practice DSA swiftly: strong theory notes, code templates in C++/Python/Java, guided playlists, and handpicked problem sets arranged by difficulty.


🗺️ Learning roadmap

Stage 0 — Basics
  • Time & Space Complexity, Recurrence (Master Theorem)
  • Arrays, Strings (two pointers, sliding window)
  • Stacks, Queues, Deque
  • Hashing: maps/sets, frequency tables
Stage 1 — Core DS
  • Linked Lists (SLL/DLL), fast–slow, reversal, cycle
  • Trees (BST, Traversals, LCA, Diameter)
  • Heaps / Priority Queue, Disjoint Set (DSU)
Stage 2 — Graphs
  • BFS/DFS (iterative & recursive), Toposort (Kahn/DFS)
  • Shortest Paths (Dijkstra, Bellman-Ford), MST (Kruskal/Prim)
  • Strongly Connected Components (Kosaraju/Tarjan)
Stage 3 — Dynamic Programming
  • Knapsack (0/1, Unbounded), Subset/Partition
  • DP on Strings (LCS/LPS/Edit Distance), LIS variants
  • DP on Trees/Graphs, Bitmask DP
Stage 4 — Advanced
  • Tries, Segment Trees/Fenwick, Sparse Table
  • Greedy proofs, Math (Combinatorics, Modulo, GCD/LCM)

🎥 Curated video playlists


🗒️ DSA sheets & checklists


🧩 Classic patterns & code templates

Two Pointers & Sliding Window
// C++
// min length subarray with sum >= target
int minSubArrayLen(int target, vector& a){
    int n=a.size(), ans=INT_MAX, s=0, l=0;
    for(int r=0;r=target){
            ans=min(ans, r-l+1);
            s-=a[l++];
        }
    }
    return ans==INT_MAX?0:ans;
}
  
Stacks & Monotonic Stack
// Next Greater Element
vector nge(vector& a){
    int n=a.size(); vector ans(n,-1), st;
    for(int i=n-1;i>=0;i--){
        while(!st.empty() && st.back()<=a[i]) st.pop_back();
        ans[i] = st.empty()? -1 : st.back();
        st.push_back(a[i]);
    }
    return ans;
}
  
Graphs (BFS/DFS/Topo)
// Iterative DFS
void dfs_iter(int s, vector>& g, vector& vis){
    stack st; st.push(s);
    while(!st.empty()){
        int u=st.top(); st.pop();
        if(vis[u]) continue; vis[u]=1;
        for(int v: g[u]) if(!vis[v]) st.push(v);
    }
}

// Kahn's Toposort vector toposort(int n, vector<vector>& g){ vector indeg(n); queue q; for(int u=0;u<n;u++) for(int v:g[u]) indeg[v]++; for(int i=0;i<n;i++) if(!indeg[i]) q.push(i); vector ans; while(!q.empty()){ int u=q.front(); q.pop(); ans.push_back(u); for(int v:g[u]) if(--indeg[v]==0) q.push(v); } return ans; }

Dynamic Programming (Knapsack)
// 0/1 Knapsack - O(n * W)
int knapsack(vector& wt, vector& val, int W){
    int n=wt.size(); vector dp(W+1,0);
    for(int i=0;i=wt[i]; --w)
            dp[w]=max(dp[w], dp[w-wt[i]]+val[i]);
    }
    return dp[W];
}
  
Trees (LCA, Diameter)
// LCA (Binary Lifting) sketch
// build up[j][v] = 2^j-th ancestor; tin/tout for is_ancestor
  

🧪 Practice sets

LeetCode

  • Easy: Two Sum, Merge Two Lists, Valid Parentheses, Best Time to Buy/Sell I
  • Medium: 3Sum, Group Anagrams, Longest Substring w/o Repeat, Course Schedule, Word Break
  • Hard: Median of Two Sorted Arrays, N-Queens, Edit Distance, Regular Expression Matching
  • NeetCode RoadmapStriver SDE Sheet

HackerRank

  • Warmup: Solve Me First, Simple Array Sum, Diagonal Difference
  • Data Structures: Arrays DS, Sparse Arrays, Balanced Brackets, QHEAP1
  • Algorithms: BFS/DFS, Dijkstra, Kruskal (MST), DP (Coin Change)

📁 Repo structure

DSA/
├─ arrays/
├─ strings/
├─ linked-list/
├─ stack-queue/
├─ hash/
├─ trees/
├─ graphs/
├─ dp/
├─ math/
├─ templates/        # reusable snippets (fast I/O, DSU, segtree)
├─ notes/            # concise topic notes (.md or .pdf)
└─ contests/         # timed practice & editorials

🤝 Contributing

  1. Fork the repo
  2. Create a feature branch: git checkout -b feat/topic-name
  3. Commit with clear messages and include problem links
  4. Open a PR with a short summary, approach, and complexity

Style:

  • One problem per folder with README.md (statement, idea, complexity)
  • Include multiple languages when possible (C++/Python/Java)
  • Prefer iterative solutions and add edge-case tests


📄 License

MIT — do what you love, but please attribute.


Tip: Star the repo ⭐ and track your progress by checking off sheets above.

About

This is a repository to study and understand DSA concepts. Notes, Codes and more...

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors