Skip to content

LeetCode-Solutions : A curated collection of solutions to LeetCode problems, implemented in C++ and Java. It covers a wide range of topics like Data Structures, Algorithms, Dynamic Programming, Greedy, Recursion, and more — with clean, efficient, and well-commented code to help understand the logic behind each solution.

License

Notifications You must be signed in to change notification settings

etsryn/LeetCode-Solutions

Repository files navigation

LeetCode-Solutions

A curated repository of optimized solutions for LeetCode challenges implemented in C++ and Java. This repository serves as a reference for algorithmic problem solving, interview preparation, and mastering data structures.


Table of Contents


Overview

LeetCode-Solutions is a collection of well-documented, efficient, and clean code solutions to a wide array of LeetCode problems. Each solution is accompanied by explanations that highlight the approach, complexity analysis, and any relevant edge cases. The main focus is on providing clear, modular code written in C++ and Java to facilitate learning and review.


Repository Structure

The repository is organized by programming language and then by problem categories:

LeetCode-Solutions/

├── Attached Images/
│   ├── Qno_Fno_no.jpg
│   | 
│   .
│   .
│   .
│   .
│   |
|   └── Qno_Fno_no.jpg
|
├── LeetCode-Streak/
│   ├── Daily Questions 1
│   | 
│   .
│   .
│   .
│   .
│   |
|   └── Daily Questions nᵗʰ
|
├── Solutions/
│   ├── Two-Sum.md/
│   ├── Add-Two-Numbers.md/
│   .
│   .
│   .
│   |
│   └── nᵗʰ Question
|
├── CONTRIBUTING.md
├── LICENSE
├── LangParity C++ & Java.md
├── LeetCode-Solutions-Index.md
└── README.md
  • LeetCode-Streak Folder: Contains LeetCode's Daily Challenge Problem's Solution -- Maintaining Streak
    • File Naming: Solutions are named by their LeetCode problem number and title for easy navigation
  • Solutions Folder: Contains LeetCode's Problems solved using languages either C++ or Java or both
    • File Naming: Solutions are named by their LeetCode problem title for easy navigation.
  • Documentation Files:
    • README.md: Provides an overview and usage instructions.
    • CONTRIBUTING.md: Outlines guidelines for contributing to the repository.
    • LeetCode-Solutions-Index.md: Outlines guidelines for accessing question's solution easily -- Indexing

Languages

  • C++: Utilizes modern C++ standards (e.g., C++11/14/17) and STL for robust and optimized solutions.
  • Java: Emphasizes clarity and efficiency using core Java libraries.

Usage

Compiling and Running Solutions

C++ Example

To compile a C++ solution (for example, the Two Sum problem):

Compilation

g++ -std=c++17 -o solution 001_Two_Sum.cpp

then

Execution

./solution

or

Compilation

g++ 001_Two_Sum.cpp

then

Execution

./a.exe

Java Example

To compile and run a Java solution (for example, the Two Sum problem):

Compilation

javac 001_Two_Sum.java

then

Execution

java 001_Two_Sum

Feel free to adapt the commands based on your system configuration and project structure.


Contributing

Contributions are welcome! If you’d like to add a new solution, improve an existing one, or fix any issues, please follow these steps:

  1. Fork the Repository: Create your own fork of the project.
  2. Create a Branch: Use a descriptive name for your branch (e.g., feature/add-two-sum-solution).
  3. Commit Changes: Follow the coding style used in the repository. Include comments explaining your approach and complexity.
  4. Submit a Pull Request: Provide a clear description of your changes and reference any related LeetCode problems.

Please review our CONTRIBUTING.md for detailed guidelines on code style, commit messages, and testing.


Code Quality

Each solution in this repository includes:

  • Problem Description: A concise summary of the LeetCode problem.
  • Approach Explanation: Detailed comments that explain the logic, algorithm, and complexity (both time and space).
  • Clean Code: Emphasis on readability, modular design, and best practices.
  • Test Cases: Example inputs and expected outputs are provided when applicable to verify the solution.

License

This project is licensed under the MIT License. You are free to use, modify, and distribute the code as long as proper attribution is provided.


Happy coding and best of luck on your journey to mastering algorithms and data structures!

About

LeetCode-Solutions : A curated collection of solutions to LeetCode problems, implemented in C++ and Java. It covers a wide range of topics like Data Structures, Algorithms, Dynamic Programming, Greedy, Recursion, and more — with clean, efficient, and well-commented code to help understand the logic behind each solution.

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published