This repository contains some solutions for the challenges from AlgoExpert Coding Questions.
📝 Note:
I've not finished all challenges yet, and I'm constantly updating this repository with new solutions, new structures, new tests, etc. So, if you want to see the most recent changes, check the last challenge that is marked as completed in the challenge list section below.
| 😎 Easy (31) | 😅 Medium (73) | 😰 Hard (58) | 😱 Very Hard (38) |
|---|---|---|---|
More... |
More... |
More... |
More... |
- Automatic tests after every commit - using Git Hooks and Jest
- Automatic tests after every push - using Github Actions and Jest
- Common folder - to help you reuse code
- Each challenge has its own folder - to help you organize your solutions
- Each challenge has its own test file - to help you run the tests for a specific challenge
- Each challenge has its own case test file - to help you organize your test cases
- Each challenge has its own README.md file - to help you understand the challenge
- Each challenge has its own solution file - to help you write your solution
- Easy to test your solution - just create a new solution file and update the test file with your solution
- Makefile - to help you run the tests, create new challenges and commit your solutions
- Easy to commit your solution - just run
make commitand it will commit with the messagefeat(CHALLENGE_NAME): add solution {SOLUTION_NUMBER} - Easy to create new challenges - just run
make newand it will create the folder, files and README.md file for you, using templates - Easy to create new solutions - just run
make new-solutionand it will create the solution file for you, using templates - Easy to run the tests - just run
make testand it will run all tests - You can customize the templates - just update the
scripts/templatesfolder - Easy to debug in VSCode - there is a
launch.jsonfile with a debug configuration for the current open challenge tab in VSCode - Auto discover last challenge completed to create new solution when executing
make new-solutioncommand - Auto discover next challenge to be completed to create new challenge when executing
make newcommand - Auto update solution been tested when executing
make new-solutioncommand
- Replicate function assignature from
solution-0.tsto new file when executingmake new-solutioncommand - After creating a new challenge, open all new files in VSCode
- Update all challenges with the new structure after finishing the challenge list
- Auto update number of challenges completed in each level after finishing each challenge when executing
make commitcommand - Move root config files to a
.configfolder - Create a
docsfolder with aREADME.mdfile with some tips and tricks
My method for solving the challenges is:
- Preparation
- Create the challenge folder and files (using the
make newcommand)
- Create the challenge folder and files (using the
- 1st Step
- Read the challenge description
- Draw a solution
- Write the solution in TypeScript without looking at the solution hints
- Run the tests (using the
make test-changedcommand) - Refactor the solution
- Repeat steps 4 and 5 until all tests pass
- Evaluate the complexity of the solution
- Commit the solution (using the
make commitcommand)
- 2dn Step
- Verify the solution hints
- Compare my solution with the solution hints
- Try to improve my solution or create a new one based on the solution hints (using the
make new-solutioncommand) - Repeat steps 4 to 10 until I'm satisfied with the solution
- Commit the solution (using the
make commitcommand)
- 3rd Step
- Watch the solution video
- Implement other solutions from the video or refactor my solution based on the video
- Commit the solution (using the
make commitcommand)
flowchart LR
START((Preparation)) --> one
subgraph one[1st Step]
A[Read] --> B[Draw]
B --> C[Code]
C --> D[Tests]
D --> C
D --> I[Complexity]
I --> R[Commit]
end
subgraph two[2nd Step]
R --> J[Hints]
J --> K[Compare]
K --> L[Refactor]
L --> M[Tests]
M --> L
M --> S[Commit]
end
subgraph three[3rd Step]
S --> N[Video]
N --> O[Code]
O --> P[Code/Refactor]
P --> Q[Tests]
Q --> P
Q --> T[Commit]
end
one -.-> two
two -.-> three
three --> End(((End)))
git clone git@github.com:filipe1309/algoexpert-solutions.gitcd algoexpert-solutionsmake installI have created a Makefile to help you run the tests.
Run all tests:
make testRun a specific test:
make test t=CHALLENGE_NAMEExample:
make test t=two-number-sum
Run changed tests:
make test-changedI have also created a Makefile with some extra commands.
make new [n=CHALLENGE_NAME] [l=CHALLENGE_LEVEL] [c=CHALLENGE_CATEGORY]📝 Example:
make new(fill the prompts) ORmake new n=two-number-sum l=easy c=arraysLevels:
easy,medium,hard,very-hard
This will create:
- a folder (
src/easy/two-number-sum) - a
solution-0.tsfile (the file where you will write your solution, you can create more if you want and update the test file) - a test file
solution.spec.ts - a case test file
cases.ts - a
README.mdfile
make commit [m=COMMIT_MESSAGE]📝 Example:
make commit m="feat: add two number sum solution"
if you don't pass themargument, it will commit with the message
feat(CHALLENGE_NAME): add solution {SOLUTION_NUMBER}
make new-solution [n=CHALLENGE_NAME_SNAKE] [l=CHALLENGE_LEVEL_LOWER]📝 Example:
make new-solution [l=easy] [n=two-number-sum]ORmake new-solution(fill the prompts)
This will create a new solution file solution-{SOLUTION_NUMBER}.ts and update the test file.
If
solution-0.tsalready exists, it will createsolution-1.tsand update index.ts file and the test file. And so on...
Help command:
make helpPull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
- AlgoExpert
- New Year Gift - Curated List of Top 75 LeetCode Questions to Save Your Time
- ShubcoGen Template™
- Git Hooks without extra dependencies like Husky in Node.js project
- TypeScript + Jest
- Testes Unitários com Node.js, Jest e TypeScript
- What is Big O Notation Explained: Space and Time Complexity
- Utilizando Path Mapping no TypeScript
- Paths Mapping
- Module Resolution
- Understanding the Levenshtein Distance Equation for Beginners
- Stable Marriage Problem - Numberphile
- Stable Marriage Problem (the math bit)
Done with :heart: by Filipe Leuch Bonfim 🖖