My personal solutions for the 100 Rust Interview Problems
Complete solutions with explanations, test cases, and complexity analysis
π Problems β’ π Quick Start β’ οΏ½ Progress β’ π€ Contributing
π¨ IMPORTANT: This repository is for practicing and learning Rust!
- Fork this repository to your own GitHub account
- Solve each problem BY YOURSELF β No AI assistance!
- Track your progress in PROGRESS.md
- Learn from your mistakes and improve your skills
π§ The real learning happens when YOU solve the problems! Using AI defeats the purpose of practice.
- π― 100 Curated Problems β From basic syntax to advanced algorithms
- π Clean & Idiomatic Rust β Following best practices and conventions
- π§ͺ Full Test Coverage β Every solution includes test cases
- π Complexity Analysis β Time & space complexity for each solution
- π Problem Links β Direct links to problem descriptions
- π Organized Structure β Easy navigation by difficulty and category
rust-100-problems/
βββ π Cargo.toml
βββ π README.md
βββ π src/
βββ main.rs
βββ solutions/
βββ mod.rs # Module declarations
β
βββ π’ Beginner (001-035)
β βββ p001_two_sum.rs
β βββ p002_reverse_string.rs
β βββ ...
β
βββ π‘ Intermediate (036-070)
β βββ p036_implement_stack.rs
β βββ p047_two_sum_hashmap.rs
β βββ ...
β
βββ π΄ Advanced (071-100)
βββ p071_house_robber.rs
βββ p092_lru_cache.rs
βββ ...
- Rust 1.75 or later
# Clone the repository
git clone https://github.com/aarambh-darshan/rust-100-solutions.git
cd rust-100-solutions
# Build the project
cargo build# Run all tests
cargo test
# Run tests for a specific problem
cargo test p001 # Two Sum
cargo test p042 # Linked List Cycle
cargo test p092 # LRU Cache
# Run with output
cargo test p001 -- --nocaptureBasic Syntax & Math (1-15)
| # | Problem | Difficulty | Topics |
|---|---|---|---|
| 001 | Two Sum | π’ | Arrays, Hash Map |
| 002 | Reverse String | π’ | Strings, Two Pointers |
| 003 | Palindrome Number | π’ | Math |
| 004 | FizzBuzz | π’ | Loops, Conditionals |
| 005 | Fibonacci Number | π’ | Recursion, DP |
| 006 | Factorial | π’ | Recursion |
| 007 | Count Digits | π’ | Math |
| 008 | Sum of Array | π’ | Arrays |
| 009 | Find Maximum | π’ | Arrays |
| 010 | Find Minimum | π’ | Arrays |
| 011 | Even or Odd | π’ | Math |
| 012 | Prime Number Check | π’ | Math |
| 013 | Leap Year | π’ | Math |
| 014 | Celsius to Fahrenheit | π’ | Math |
| 015 | Swap Two Numbers | π’ | Variables |
Arrays & Strings (16-35)
| # | Problem | Difficulty | Topics |
|---|---|---|---|
| 016 | Reverse Integer | π’ | Math |
| 017 | Count Vowels | π’ | Strings |
| 018 | Remove Duplicates | π’ | Two Pointers |
| 019 | Merge Sorted Arrays | π’ | Arrays |
| 020 | Valid Parentheses | π’ | Stack |
| 021 | Plus One | π’ | Arrays |
| 022 | Sqrt(x) | π’ | Binary Search |
| 023 | Climbing Stairs | π’ | DP |
| 024 | Remove Element | π’ | Two Pointers |
| 025 | Search Insert Position | π’ | Binary Search |
| 026 | Length of Last Word | π’ | Strings |
| 027 | Add Binary | π’ | Strings, Math |
| 028 | Single Number | π’ | Bit Manipulation |
| 029 | Best Time to Buy Stock | π’ | Arrays, DP |
| 030 | Pascal's Triangle | π’ | Arrays |
| 031 | Valid Anagram | π’ | Hash Map |
| 032 | First Unique Character | π’ | Hash Map |
| 033 | Intersection of Arrays | π’ | Hash Set |
| 034 | Move Zeroes | π’ | Two Pointers |
| 035 | Power of Two | π’ | Bit Manipulation |
Data Structures (36-45)
| # | Problem | Difficulty | Topics |
|---|---|---|---|
| 036 | Implement Stack | π‘ | Stack |
| 037 | Implement Queue | π‘ | Queue |
| 038 | Evaluate RPN | π‘ | Stack |
| 039 | Min Stack | π‘ | Stack, Design |
| 040 | Reverse Linked List | π‘ | Linked List |
| 041 | Merge Sorted Lists | π‘ | Linked List |
| 042 | Linked List Cycle | π‘ | Linked List, Floyd's |
| 043 | Middle of Linked List | π‘ | Linked List |
| 044 | Remove Nth From End | π‘ | Linked List |
| 045 | Palindrome Linked List | π‘ | Linked List |
HashMaps & HashSets (46-50)
| # | Problem | Difficulty | Topics |
|---|---|---|---|
| 046 | Contains Duplicate | π‘ | Hash Set |
| 047 | Two Sum HashMap | π‘ | Hash Map |
| 048 | Group Anagrams | π‘ | Hash Map, Strings |
| 049 | Top K Frequent | π‘ | Hash Map, Heap |
| 050 | Longest Consecutive | π‘ | Hash Set |
Binary Search & Sorting (51-56)
| # | Problem | Difficulty | Topics |
|---|---|---|---|
| 051 | Binary Search | π‘ | Binary Search |
| 052 | Search Rotated Array | π‘ | Binary Search |
| 053 | Find Peak Element | π‘ | Binary Search |
| 054 | First Bad Version | π‘ | Binary Search |
| 055 | Search 2D Matrix | π‘ | Binary Search |
| 056 | Sort Colors | π‘ | Dutch Flag |
Arrays & Intervals (57-67)
| # | Problem | Difficulty | Topics |
|---|---|---|---|
| 057 | Merge Intervals | π‘ | Intervals, Sorting |
| 058 | Insert Interval | π‘ | Intervals |
| 059 | Meeting Rooms | π‘ | Intervals |
| 060 | 3Sum | π‘ | Two Pointers |
| 061 | Container With Water | π‘ | Two Pointers |
| 062 | Product Except Self | π‘ | Arrays |
| 063 | Maximum Subarray | π‘ | Kadane's Algorithm |
| 064 | Spiral Matrix | π‘ | Matrix |
| 065 | Rotate Image | π‘ | Matrix |
| 066 | Set Matrix Zeroes | π‘ | Matrix |
| 067 | Valid Sudoku | π‘ | Hash Set, Matrix |
Backtracking (68-70)
| # | Problem | Difficulty | Topics |
|---|---|---|---|
| 068 | Subsets | π‘ | Backtracking |
| 069 | Permutations | π‘ | Backtracking |
| 070 | Combination Sum | π‘ | Backtracking |
Dynamic Programming (71-80)
| # | Problem | Difficulty | Topics |
|---|---|---|---|
| 071 | House Robber | π΄ | DP |
| 072 | Coin Change | π΄ | DP |
| 073 | Longest Increasing Subsequence | π΄ | DP, Binary Search |
| 074 | Unique Paths | π΄ | DP |
| 075 | Jump Game | π΄ | Greedy, DP |
| 076 | Word Break | π΄ | DP, Trie |
| 077 | Decode Ways | π΄ | DP |
| 078 | Longest Common Subsequence | π΄ | DP |
| 079 | Edit Distance | π΄ | DP |
| 080 | Maximal Square | π΄ | DP, Matrix |
Graph Algorithms (81-90)
| # | Problem | Difficulty | Topics |
|---|---|---|---|
| 081 | Number of Islands | π΄ | DFS, BFS |
| 082 | Clone Graph | π΄ | DFS, Hash Map |
| 083 | Course Schedule | π΄ | Topological Sort |
| 084 | Pacific Atlantic | π΄ | DFS, BFS |
| 085 | Word Ladder | π΄ | BFS |
| 086 | Alien Dictionary | π΄ | Topological Sort |
| 087 | Graph Valid Tree | π΄ | Union Find |
| 088 | Shortest Path Binary Matrix | π΄ | BFS |
| 089 | Network Delay Time | π΄ | Dijkstra's |
| 090 | Minimum Spanning Tree | π΄ | Kruskal's/Prim's |
System Design & Advanced (91-100)
| # | Problem | Difficulty | Topics |
|---|---|---|---|
| 091 | Implement Trie | π΄ | Trie |
| 092 | LRU Cache | π΄ | Hash Map, Linked List |
| 093 | Serialize/Deserialize Tree | π΄ | Trees, DFS |
| 094 | Design Twitter | π΄ | OOP, Heap |
| 095 | Find Median Stream | π΄ | Heap |
| 096 | Sliding Window Maximum | π΄ | Deque |
| 097 | Trapping Rain Water | π΄ | Two Pointers, Stack |
| 098 | Merge K Sorted Lists | π΄ | Heap, Linked List |
| 099 | Regular Expression | π΄ | DP, Recursion |
| 100 | N-Queens | π΄ | Backtracking |
π Track your progress: PROGRESS.md
| Difficulty | Total | Completed | Progress |
|---|---|---|---|
| π’ Beginner | 35 | 0 | |
| π‘ Intermediate | 35 | 0 | |
| π΄ Advanced | 30 | 0 | |
| Total | 100 | 0 |
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β DSA Topics β
βββββββββββββββββββ¬ββββββββββββββββββ¬ββββββββββββββββββββββββββββββ€
β Arrays β Strings β Linked Lists β
β Stacks β Queues β Hash Maps / Sets β
β Binary Search β Sorting β Two Pointers β
β Sliding Window β Recursion β Dynamic Programming β
β Backtracking β Graphs (DFS/BFS)β Trees & Tries β
β Heaps β Greedy β Bit Manipulation β
β Union Find β Topological Sortβ System Design β
βββββββββββββββββββ΄ββββββββββββββββββ΄ββββββββββββββββββββββββββββββ
Contributions are welcome! Here's how you can help:
- Fork the repository
- Create a feature branch (
git checkout -b feature/better-solution) - Commit your changes (
git commit -m 'Add optimized solution for problem X') - Push to the branch (
git push origin feature/better-solution) - Open a Pull Request
- Follow Rust naming conventions and idioms
- Include test cases for your solutions
- Add complexity analysis in comments
- Keep code clean and well-documented
| Resource | Description |
|---|---|
| 100 Rust Problems | Original problem repository |
| Rust Book | Official Rust documentation |
| Rust by Example | Learn Rust with examples |
| Rust Playground | Online Rust compiler |
This project is licensed under the MIT License - see the LICENSE file for details.
Created by Darshan Vichhi π¦β€οΈ
Fork it. Solve it. Master it. No AI allowed!