Exercises taken from the Leetcode 75 interview problem compilation. Each exercise folder has the following files:
$ tree ,<exercise-name>
,<exercise-name>
├── index.js # Solution implementation
├── package.json # Contains execution scripts
├── README.md # Problem description
└── test.js # Test cases implementation
To streamline the setup process for each exercise, you can automatically inject the common scripts
defined in leetcode-node-scripts.json
into the package.json
of each exercise directory using the
add-scripts.sh
bash script.
- Ensure you have a
package.json
file in your exercise directory (create one withnpm init -y
if necessary). - Use the
add-scripts.sh
script to inject the scripts fromleetcode-node-scripts.json
into yourpackage.json
:
# Execute from the repository root
$ ./add-scripts.sh <path-to-exercise>/package.json
After running the script, your package.json will include the following scripts from
leetcode-node-scripts.json
:
{
"start": "node index.js",
"debug": "node --inspect-brk index.js",
"test": "node test.js"
}
start
: Runs theindex.js
file to start the program. Use this when you want to run you solution.debug
: Starts the program in debug mode with--inspect-brk
, allowing you to attach a debugger and step through the code.test
: Runs thetest.js
file to execute all test cases associated with the exercise, ensuring your solution meets the specified requirements.