A collection of algorithm implementations in TypeScript, focusing on clarity, performance, and well-known problem-solving patterns.
- 🔗 Bubble Sort - Simple comparison-based sorting (O(n²) time, O(1) space)
- 🔗 Quick Sort - Efficient divide-and-conquer sorting (O(n log n) average)
- 🔗 Merge Sort - Stable divide-and-conquer sorting for linked lists (O(n log n) time, O(log n) space)
- 🔗 Binary Search - Efficient searching in sorted arrays (O(log n))
- 🔗 Exponential Search - Find range then binary search
- 🔗 Reverse Words in String - String manipulation using two pointers
- 🔗 Two Sum - Find pairs that sum to target value
- 🔗 Maximum Length Substring - Find max substring with at most 2 occurrences
- 🔗 Contains Nearby Duplicate - Detect duplicates within distance k
- 🔗 Missing Number - Find the missing number in array containing n distinct numbers in range [0, n] (O(n) time, O(1) space)
- 🔗 Binary Tree Implementation - Binary search tree with insert, search, and traversal operations
- Insert values maintaining BST property (O(log n) average, O(n) worst case)
- Search for values efficiently (O(log n) average, O(n) worst case)
- In-order traversal returning sorted values (O(n) time)
- 🔗 Build Binary Tree from Traversals - Reconstruct a binary tree from pre-order/post-order and in-order traversal sequences
- 🔗 Stack (Array) - Stack implementation using array with LIFO behavior (push, pop, peek, isFull, isEmpty)
- 🔗 Stack (Linked List) - Stack implementation using singly linked list with LIFO behavior (push, pop, peek)
- 🔗 Min Heap - Min heap implementation with insert and popMin operations using heapify up/down (O(log n) insert/extract)
- 🔗 Trie - Prefix tree implementation with insert, search, and startsWith operations
- 🔗 List Node - Basic node structure for linked lists
- 🔗 Doubly Linked List - Bidirectional linked list with add/remove operations
- 🔗 Reverse Linked List - Reverse singly linked list in-place (O(n) time, O(1) space)
- 🔗 Middle of Linked List - Find middle node using slow-fast pointer technique
- 🔗 Floyd Cycle Detection - Detect cycles using tortoise and hare algorithm
- 🔗 Merge Two Sorted Lists - Merge sorted linked lists efficiently
- 🔗 Array to Linked List - Convert array to linked list
- 🔗 Linked List to Array - Convert linked list to array
- TypeScript - Type-safe algorithm implementations
- Bun - Fast JavaScript runtime and test runner
- Biome - Code formatting and linting
# Install dependencies
bun install
# Run all tests
bun test
# Run tests in watch mode
bun test --watch
# Format code
bunx biome format --write
# Lint code
bunx biome lint --writeMIT License