AlgoExpert TS Solutions
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...
|
(back to top)
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 commit
and it will commit with the message feat(CHALLENGE_NAME): add solution {SOLUTION_NUMBER}
Easy to create new challenges - just run make new
and it will create the folder, files and README.md file for you, using templates
Easy to create new solutions - just run make new-solution
and it will create the solution file for you, using templates
Easy to run the tests - just run make test
and it will run all tests
You can customize the templates - just update the scripts/templates
folder
Easy to debug in VSCode - there is a launch.json
file 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-solution
command
Auto discover next challenge to be completed to create new challenge when executing make new
command
Auto update solution been tested when executing make new-solution
command
(back to top)
Replicate function assignature from solution-0.ts
to new file when executing make new-solution
command
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 commit
command
Move root config files to a .config
folder
Create a docs
folder with a README.md
file with some tips and tricks
(back to top)
My methodfor solving the challenges is:
Preparation
Create the challenge folder and files (using the make new
command)
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-changed
command)
Refactor the solution
Repeat steps 4 and 5 until all tests pass
Evaluate the complexity of the solution
Commit the solution (using the make commit
command)
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-solution
command)
Repeat steps 4 to 10 until I'm satisfied with the solution
Commit the solution (using the make commit
command)
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 commit
command)
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)))
Loading
(back to top)
Node.js
TypeScript
Jest
(back to top)
Node.js
(back to top)
git clone [email protected]:filipe1309/algoexpert-solutions.git
cd algoexpert-solutions
make install
(back to top)
I have created a Makefile
to help you run the tests.
Run all tests:
make test
Run a specific test:
make test t=CHALLENGE_NAME
Example:
make test t=two-number-sum
Run changed tests:
make test-changed
(back to top)
I 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=arrays
Levels:
easy
,medium
,hard
,very-hard
This will create:
a folder (src/easy/two-number-sum
)
a solution-0.ts
file (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.md
file
make commit [m=COMMIT_MESSAGE]
Example:
make commit m="feat: add two number sum solution"
if you don't pass them
argument, it will commit with the messagefeat(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.ts
already exists, it will createsolution-1.ts
and update index.ts file and the test file. And so on...
Help command:
make help
(back to top)
Pull 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.
(back to top)
MIT
(back to top)
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)
(back to top)
Done with :heart: by Filipe Leuch Bonfim ?
(back to top)