This repository contains solutions to LeetCode problems I've solved as part of my preparation for interviews with FAANG (Facebook, Amazon, Apple, Netflix, Google) and other tech companies. The goal is to document my progress and learn from the solutions shared by the community.
Each solution is stored in its own folder inside /solutions/. Each folder contains multiple files, each representing a different way to solve the same problem in variety of languages.
solutions/
0001-two-sum/
ββ brute-force.c
ββ hashmap.c
ββ backtrack.c
ββ backtrack.js
ββ two-pointers.py
ββ metadata.json
metadata.json includes the problem ID, title, tags, difficulty, and a link to the LeetCode problem (later used for analysis, parsing). Example:
{
"id": 1,
"title": "Two Sum",
"difficulty": "Easy",
"tags": ["hash-table", "array", "brute-force", "two-pointers"],
"link": "https://leetcode.com/problems/two-sum/description/"
}Files and folders are named using kebab-case (e.g., brute-force.js, two-pointers.py). Each solution file starts with a single-line comment declaring time and space complexity, like:
// time: O(n)
// space: O(n)The comment style (//, #, etc.) is automatically chosen based on the language -- if you use create-solution.js utility function. No need for a title in the comment as the filename already makes the approach obvious.
I usually work in the terminal, so I made some CLI tools to make things easier.
They're all in the /utils/ folder.
You can run them from the project root using npm run <script>. We have the following utility scripts:
create-problem: makes a new folder in/solutions/with starter files
We enforce strict commit naming. Use the following format:
solve: 0001 (js) # New solution
fix: handle edge case # Fix an error
perf: optimize logic # Improve time/space complexity
docs: update readme # Documentation only
chore: update deps # Maintenance, dependencies
style: reformat code # Code style changes
refactor: simplify # No behavior change
Run npm install to install Commitizen. It reads this config to enforce the format.
Use git cz to commit with the correct format automatically.
Want to contribute? Great. Please follow these rules:
- Star the repo
- Strictly follow file and folder naming conventions.
- Include the header comment in all solution files.
- Update or add
metadata.json. You can use utility functions to help with this. - Write clean, readable code.
Note that if you are not sure about time and space complexity of your solution, you can take advantage of "Analyze Complexity" feature on LeetCode:
This repository is shared for collaboration and learning. Copying and pasting code directly without understanding it is discouraged. Use these solutions as references and focus on understanding the reasoning behind each implementation.

