Skip to content

AbrarRagib/rustlab

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🦀 Rust Mastery

Learn Rust from zero to advanced — then prove it with real data structures, algorithms, and interview problems.

Every file is runnable, tested, and heavily commented. Zero external dependencies — pure std.

rust-mastery/
├── tutorial/     14 chapters, beginner → very advanced (each is a runnable example)
├── dsa/          9 data structures built from scratch, fully tested
├── algorithms/   Classic algorithms: sorting, searching, DP, graphs, strings
└── problems/     Top interview problems (LeetCode classics) with tests

Quick Start

# Run any tutorial chapter:
cargo run --example 01_basics

# Run ALL 71 tests:
cargo test --workspace

# Test just one crate:
cargo test -p dsa

📚 The Learning Path

Follow the chapters in order. Each one builds on the last.

🟢 Beginner

# Chapter What you'll learn
01 01_basics Variables, types, control flow, functions, expressions
02 02_ownership_borrowing The heart of Rust: moves, borrows, slices
03 03_structs_enums Structs, methods, enums, Option, pattern matching
04 04_collections Vec, String, HashMap, HashSet, VecDeque, BTreeMap
05 05_error_handling Result, the ? operator, custom error types

🟡 Intermediate

# Chapter What you'll learn
06 06_generics_traits Generics, trait bounds, default methods, dyn Trait
07 07_lifetimes What 'a really means, elision, 'static
08 08_closures_iterators Fn/FnMut/FnOnce, lazy iterators, building your own
09 09_smart_pointers Box, Rc, RefCell, Weak, breaking cycles

🔴 Advanced

# Chapter What you'll learn
10 10_concurrency Threads, channels, Arc<Mutex<T>>, scoped threads
11 11_macros Write your own macro_rules! (build vec! and hashmap! yourself)
12 12_unsafe Raw pointers, safe wrappers around unsafe cores
13 13_async_from_scratch Build an async executor with only std — demystify tokio
14 14_capstone_project Everything combined into a real mini-application

🏗️ Data Structures (dsa/)

Built from scratch, each with tests explaining the invariants:

  • Stack + MinStack (O(1) minimum)
  • Queue + the two-stack queue (classic interview question)
  • Linked List — the famous "hard in Rust" structure, with iterative reverse(), a custom iterator, and a stack-safe Drop
  • Binary Search Tree — insert, search, in-order traversal, height
  • Min-Heap — sift-up/sift-down from scratch + O(n) heapify
  • Graph — adjacency list, BFS, DFS, shortest distances, connected components
  • Trie — prefix search + autocomplete
  • Union-Find — path compression + union by rank
  • LRU Cache — the top system-design interview question

⚙️ Algorithms (algorithms/)

  • Sorting: bubble, insertion, merge, quick, counting — with a complexity comparison table
  • Searching: binary search, lower/upper bound, binary search on the answer
  • Dynamic Programming: Fibonacci (memo + O(1) space), coin change, LCS, 0/1 knapsack, LIS in O(n log n), edit distance
  • Graphs: Dijkstra, topological sort (Kahn's), cycle detection, course schedule
  • Strings: KMP, Rabin–Karp rolling hash, palindrome checks

🎯 Top Interview Problems (problems/)

Problem Difficulty Technique
Two Sum Easy HashMap one-pass
Best Time to Buy/Sell Stock Easy Running minimum
Valid Parentheses Easy Stack
Contains Duplicate Easy HashSet
Maximum Subarray Medium Kadane's algorithm
Product of Array Except Self Medium Prefix/suffix products
Merge Intervals Medium Sort + sweep
Rotate Array Medium Triple reverse
Longest Substring Without Repeats Medium Sliding window
Group Anagrams Medium Sorted-key buckets
Longest Palindromic Substring Medium Expand around center
Longest Consecutive Sequence Medium HashSet run-starts
Number of Islands Medium Flood fill DFS
Word Search Medium Grid backtracking
Trapping Rain Water Hard Two pointers
Sliding Window Maximum Hard Monotonic deque
Median of Two Sorted Arrays Hard Binary search partition
Largest Rectangle in Histogram Hard Monotonic stack
First Missing Positive Hard O(1)-space cyclic sort
Merge k Sorted Lists Hard k-way min-heap
Minimum Window Substring Hard Shrinking sliding window
Word Ladder Hard BFS on implicit graph
Regular Expression Matching Hard 2-D DP
Burst Balloons Hard Interval DP ("last balloon" trick)
Distinct Subsequences Hard 1-D DP, reverse iteration
Longest Valid Parentheses Hard Index stack with sentinel
N-Queens (count + board) Hard Backtracking with O(1) pruning
Sudoku Solver Hard Constraint backtracking

💡 How to Use This Repo

  1. Read a chapter, run it, then break it — change code, re-run, read the compiler's (excellent) errors.
  2. Re-implement from memory: after studying a structure in dsa/, delete the body and rebuild it until the tests pass again.
  3. Use tests as specs: every #[cfg(test)] block shows exactly what correct behavior looks like.
  4. Go further: AVL/Red-Black trees, B-trees, segment trees, procedural macros, tokio, Pin deep-dives, lock-free structures.

📖 Recommended Companions


Everything compiles on stable Rust with no dependencies. cargo test --workspace = 71 green tests. 🚀

About

Learning Rust by building: complete curriculum + DSA + 28 interview problems, every solution tested and commented.

Topics

Resources

Stars

5 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages