/algo-practice

Learning algorithm by solving problems

Primary LanguageJavaScript

Algorithm Practice with Node.js

This repository contains solutions to common algorithm problems implemented in Node.js, along with unit tests to verify their correctness. Jest is used as the testing framework.

Schedule for practice

  • Daily:

    • Solve 1-2 algorithm problems.
    • Review related sections in the cheat sheet.
  • Weekly:

    • Review the entire cheat sheet.
    • Identify weak areas and plan focused practice for the next week.

Getting Started

Prerequisites

Ensure you have Node.js installed. Download it from nodejs.org.

Installation

  1. Clone the repository:
    git clone https://github.com/rupeshtiwari/algo-practice.git
    cd algo-practice
  2. Install dependencies:
    npm install

Project Structure

algo-practice/
├── node_modules/
├── src/
│   └── twoSum.js        # Algorithm implementations
├── tests/
│   └── twoSum.test.js   # Unit tests for the algorithms
├── docs/
│   └── twoSum.md        # Detailed explanations and documentation
├── package.json         # Project configuration and dependencies
├── package-lock.json    # Dependency tree lock file
└── README.md            # Project overview and setup instructions

Running Tests

To execute the unit tests, run:

npm test

Adding New Algorithms

  1. Create a new JavaScript file in the src directory:
    touch src/newAlgorithm.js
  2. Implement your algorithm in the new file.
  3. Create a corresponding test file in the tests directory:
    touch tests/newAlgorithm.test.js
  4. Write test cases for your algorithm in the test file.

Documentation

For detailed explanations and documentation, visit the docs.

Contributing

Fork the repository and create a pull request with your changes. Ensure you add corresponding test cases for any new algorithms you implement.

License

This project is licensed under the MIT License - see the LICENSE file for details.


Happy coding!