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