Skip to content

IbrahimIjai/dsa-rust-ts

Repository files navigation

πŸš€ DSA Learning Journey

A comprehensive collection of Data Structures and Algorithms implementations in both Rust and TypeScript/JavaScript. Perfect for learning, practicing, and mastering DSA concepts with side-by-side language comparisons.

πŸ“š Documentation


πŸ“š New Structure - Topic-Based Learning

topics/
β”œβ”€β”€ arrays/
β”‚   β”œβ”€β”€ kadanes-algorithm/
β”‚   β”‚   β”œβ”€β”€ README.md          # Problem explanation
β”‚   β”‚   β”œβ”€β”€ solution.ts        # TypeScript implementation
β”‚   β”‚   └── rust/
β”‚   β”‚       β”œβ”€β”€ Cargo.toml
β”‚   β”‚       └── src/main.rs    # Rust implementation
β”‚   β”œβ”€β”€ two-sum/
β”‚   └── ...
β”œβ”€β”€ linked-lists/
β”œβ”€β”€ trees/
β”œβ”€β”€ graphs/
β”œβ”€β”€ recursion/
β”œβ”€β”€ dynamic-programming/
└── ...

🎯 Learning Path

1. Arrays & Strings (Start here!)

  • Two Sum - topics/arrays/two-sum/
  • Kadane's Algorithm (Maximum Subarray) - topics/arrays/kadanes-algorithm/
  • Sliding Window Maximum
  • Product of Array Except Self
  • Container With Most Water

2. Linked Lists

  • Reverse Linked List
  • Detect Cycle
  • Merge Two Sorted Lists
  • Remove Nth Node From End

3. Stacks & Queues

  • Valid Parentheses
  • Min Stack
  • Implement Queue using Stacks

4. Trees

  • Binary Tree Traversal (Inorder, Preorder, Postorder)
  • Maximum Depth of Binary Tree
  • Lowest Common Ancestor
  • Validate BST

5. Graphs

  • DFS & BFS
  • Number of Islands
  • Course Schedule
  • Dijkstra's Algorithm

6. Dynamic Programming

  • Fibonacci Numbers
  • Climbing Stairs
  • Longest Common Subsequence
  • Knapsack Problem

7. Sorting & Searching

  • Binary Search
  • Quick Sort
  • Merge Sort
  • Heap Sort

πŸš€ Quick Start

Prerequisites

For TypeScript/JavaScript:

npm install

For Rust:

Running Examples

TypeScript/JavaScript

# Run any TypeScript solution
npm run dev topics/arrays/kadanes-algorithm/solution.ts

# Or use ts-node directly
npx ts-node topics/arrays/two-sum/solution.ts

Rust

# Run any Rust solution by package name
cargo run -p kadanes-algorithm
cargo run -p two-sum

# Run with tests
cargo test -p kadanes-algorithm

# Run all tests
cargo test --workspace

Testing Your Understanding

Each problem includes:

  • πŸ“– README.md - Problem statement, examples, complexity analysis
  • πŸ’» solution.ts - TypeScript implementation with examples
  • πŸ¦€ rust/src/main.rs - Rust implementation with examples
  • βœ… Tests - Unit tests in both languages

πŸ“– How to Use This Repository

For Learning

  1. Read the problem in the topic's README
  2. Try to solve it yourself first
  3. Compare your solution with the provided implementations
  4. Run the code to see it in action
  5. Modify and experiment to deepen understanding

For Practice

  1. Pick a topic from the learning path
  2. Implement in your preferred language first
  3. Then implement in the other language
  4. Compare both approaches and learn language-specific patterns

For Interview Prep

  1. Focus on common patterns (sliding window, two pointers, etc.)
  2. Practice explaining complexity analysis
  3. Implement both brute force and optimized solutions
  4. Run tests to verify correctness

πŸ’‘ Tips

  1. Don't rush - Understand the 'why' behind each algorithm
  2. Compare languages - See how Rust and TypeScript approach the same problem
  3. Run the code - Don't just read, execute and experiment
  4. Write tests - Validate your understanding
  5. Explain out loud - If you can teach it, you know it

🌟 Why Both Languages?

TypeScript/JavaScript:

  • High-level, expressive syntax
  • Great for interviews and web development
  • Quick prototyping and iteration

Rust:

  • Systems programming mindset
  • Memory safety and performance
  • Teaches low-level concepts
  • Growing in popularity for backend and systems

Learning both gives you:

  • Broader perspective on problem-solving
  • Better understanding of time/space tradeoffs
  • Appreciation for different programming paradigms

πŸ“š Reference Library (Legacy)

The resources/ folder contains additional algorithm and data structure implementations for reference.

Algorithms

Damerau Levenshtein Distance

Euler's Totient

Fibonacci Numbers

Fisher–Yates Shuffle

Levenshtein Distance

Linear Congruential Generator

Lucas Numbers

Mersenne Twister

Phi

Sieve of Eratosthenes

Search Algorithms

Binary Search

Exponential Search

Interpolation Search

Linear Search

Ternary Search

Hash Algorithms

djb2

sdbm

loselose

Sort Algorithms

Bubble Sort

Comb Sort

Heapsort

Insertion Sort

Merge Sort

Quicksort

Selection Sort

Shellsort

Data Structures

AVL Tree

Binary Search Tree

Binary Tree

Circular Doubly Linked List

Circular Linked List

Deque

Dictionary

Doubly Linked List

Graph

Hash Table

Linked List

Queue

Red Black Tree

Skip List

Stack

Tree

Trie

Unrolled Linked List

Licence

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published