A TypeScript-based collection of data structures and algorithms implementations, designed for learning and practice. Built with Bun runtime for fast execution and modern JavaScript features.
- Modular Architecture: Each algorithm is implemented as a separate module
- Dynamic Loading: Algorithms are loaded on-demand using a registry system
- TypeScript Support: Full type safety and modern TypeScript features
- Fast Runtime: Powered by Bun for optimal performance
- Easy CLI Interface: Simple command-line interface to run algorithms
- Bun runtime installed on your system
- Clone the repository:
git clone <repository-url>
cd nleetcode
- Install dependencies:
bun install
- Bubble Sort: Simple comparison-based sorting algorithm
- Binary Search: Efficient search algorithm for sorted arrays
bun run list
# or
bun run start --list
bun run start <algorithm-name> [arguments]
Bubble Sort with default data:
bun run start bubble-sort
Bubble Sort with custom data:
bun run start bubble-sort 64 34 25 12 22 11 90
Binary Search:
bun run start binary-search [arguments]
nleetcode/
├── src/
│ ├── algorithms/
│ │ ├── searching/
│ │ │ └── binary-search.ts
│ │ └── sorting/
│ │ └── bubble-sort.ts
│ ├── main.ts # Entry point and CLI handler
│ └── registry.ts # Algorithm registry for dynamic loading
├── package.json
├── tsconfig.json
└── README.md
bun run dev
This will restart the application automatically when you make changes to the source code.
- Create your algorithm file in the appropriate directory under
src/algorithms/
- Implement your algorithm with the following structure:
export function main(argv: string[]) {
// Your algorithm implementation
// argv contains command-line arguments
}
- Register your algorithm in
src/registry.ts
:
export const registry: Record<string, Loader> = {
// ... existing algorithms
'your-algorithm': async () =>
await import('./algorithms/category/your-algorithm.ts'),
};
- Each algorithm should export a
main
function that accepts string arguments - Use TypeScript for type safety
- Include console output to demonstrate the algorithm's working
- Handle edge cases appropriately
- Follow consistent code formatting
- Fork the repository
- Create a feature branch
- Implement your algorithm following the project structure
- Add your algorithm to the registry
- Test your implementation
- Submit a pull request
This project is private and intended for educational purposes.
This project is designed to help you understand:
- Data structures and algorithms implementation
- TypeScript module system
- Dynamic imports and registry patterns
- Command-line interface development
- Modern JavaScript runtime features (Bun)
Happy coding! 🚀