A Terminal User Interface (TUI) application for practicing common coding interview questions in Rust. Each question includes extensive beginner-friendly comments explaining how to solve it from scratch, along with Rust-specific concepts and best practices.
- Interactive TUI: Navigate questions with arrow keys, run them with Enter
- 20 Interview Questions across 4 categories:
- Classic Problems (FizzBuzz, Fibonacci, Palindrome, Two Sum, Reverse String)
- Data Structures (Linked List, Binary Tree, Stack, Queue, Valid Parentheses)
- Algorithms (Binary Search, QuickSort, MergeSort, BFS, DFS)
- String Manipulation (Anagram Check, Longest Substring, Common Prefix, Permutations, Group Anagrams)
- Educational Comments: Every question includes step-by-step explanations
- Live Execution: See the output of each algorithm immediately
- Full-Screen Results: Clean, readable output view
- Rust 1.70 or later (install from rustup.rs)
# Clone the repository
git clone https://github.com/davidcanhelp/rust-study.git
cd rust-study
# Build and run
cargo run
# Or build optimized release version
cargo build --release
./target/release/rust-interview-questions- ↑/↓ Arrow Keys: Navigate through the question menu
- Enter: Run the selected question
- ESC or B: Return to menu from results view
- Q: Quit the application
┌─────────────────────────────────────────────────────────┐
│ Rust Interview Questions │
└─────────────────────────────────────────────────────────┘
┌──────────────────────────────────────────────────────────┐
│ Select a Question (↑/↓ to navigate, Enter to run, Q to quit) │
│ │
│ >> 1. FizzBuzz - Classic programming challenge │
│ 2. Fibonacci - Generate Fibonacci sequence │
│ 3. Palindrome - Check if string is palindrome │
│ ... │
└──────────────────────────────────────────────────────────┘
Each question runs and displays:
- The output of the algorithm
- Explanation of the approach
- Time and space complexity analysis
rust-study/
├── Cargo.toml # Project dependencies and metadata
├── README.md # This file
├── LICENSE # MIT License
└── src/
├── main.rs # TUI event loop and terminal setup
├── app.rs # Application state management
├── ui.rs # UI rendering with ratatui
└── questions/
├── mod.rs # Question registry
├── classic.rs # Classic interview questions
├── data_structures.rs # Data structure implementations
├── algorithms.rs # Sorting and searching algorithms
└── strings.rs # String manipulation problems
Each question file includes:
- Problem Statement: Clear description of what to solve
- How to Solve from Scratch: Step-by-step approach
- Rust Concepts: Explanation of language features used
- Complexity Analysis: Time and space complexity
- Working Implementation: Fully commented code
- Ownership & Borrowing: Understanding
&T,&mut T, and moved values - Option & Result: Handling nullable values and errors
- Pattern Matching: Using
matchandif let - Iterators: Powerful functional-style data processing
- Collections: Vec, HashMap, VecDeque
- Traits: Using and implementing traits
- Generics: Writing reusable code
- Box & Smart Pointers: Heap allocation and recursive types
Open src/questions/classic.rs and find the run_fizzbuzz() function. You'll see:
// ============================================================================
// FIZZBUZZ
// ============================================================================
// PROBLEM: Print numbers from 1 to 100, but:
// - For multiples of 3, print "Fizz"
// - For multiples of 5, print "Buzz"
// - For multiples of both 3 and 5, print "FizzBuzz"
//
// HOW TO SOLVE FROM SCRATCH:
// 1. Loop through numbers 1 to 100
// 2. Check if divisible by both 3 and 5 first (order matters!)
// ...- Open the appropriate file in
src/questions/(or create a new one) - Write your question function:
fn run_my_question() -> String { let mut output = String::from("My Question:\n\n"); // Your implementation here output }
- Register it in the module's
get_questions()function:Question::new("My Question", "Description", run_my_question)
- Edit
src/ui.rsto change colors, layout, or styling - Uses the ratatui library
- All UI rendering is in
render_menu()andrender_results()
- ratatui: Terminal UI framework
- crossterm: Cross-platform terminal manipulation
- Rust Standard Library: Collections, iterators, and more
- The Rust Book: doc.rust-lang.org/book
- Rust by Example: doc.rust-lang.org/rust-by-example
- Rustlings: Small exercises to learn Rust
- LeetCode: Practice more interview questions
- Time Complexity Cheat Sheet: bigocheatsheet.com
- VisuAlgo: Algorithm visualizations
Feel free to:
- Add more interview questions
- Improve explanations
- Fix bugs or typos
- Enhance the UI
MIT License - see LICENSE file for details.
DavidCanHelp
Happy Learning! 🦀
Remember: The best way to learn is by doing. Try implementing these algorithms yourself before looking at the code, then compare your solution with the provided implementation.