A dynamic Data Structures and Algorithms practice system that allows you to solve problems and test your solutions in real-time.
- Node.js (version 14 or higher)
- npm or yarn
- Clone or download the project
- Navigate to the project directory:
cd dsa
- Install dependencies (if any):
npm install
node runFile.js
The system will randomly select problems from the available categories:
- Array Problems (currently active)
- String Problems (commented out)
- Linked List Problems (commented out)
For each problem, you'll see:
- Problem Name: Description of what you need to solve
- Input: Sample input data
- Expected Output: What your solution should return
- Input Format: How the input parameters are structured
When prompted, you can use these commands:
Command | Action |
---|---|
r or run |
Run your current solution against test cases |
s or skip |
Skip to the next problem |
q or quit |
Exit the application |
Read the problem description, input format, and expected output carefully.
Open solution.js
in your preferred code editor and modify the solve
function:
function solve(arr) {
// Your solution code here
// Update the parameters as needed based on the problem
// Example: Reverse an array
return arr.reverse();
}
- Save your changes in
solution.js
- Go back to the running application
- Type
r
and press Enter to run the test - The system will automatically reload your updated solution
- If tests fail, you'll see detailed error information
- Modify your solution and test again
- You have 3 attempts per problem before it moves to the next one
- Real-time Updates: Modify your solution while the program is running
- Automatic Reload: No need to restart the application
- Live Testing: Test changes immediately
- First Failure Focus: Shows only the first failed test case
- Detailed Error Information: Input, your output, and expected output
- Attempt Limiting: Maximum 3 attempts per problem to prevent getting stuck
- Array Problems: 7 problems covering various array manipulation techniques
- String Problems: 3 problems for string algorithms
- Linked List Problems: 3 problems for linked list operations
dsa/
βββ runFile.js # Main application file
βββ solution.js # Your solution file (modify this)
βββ helperUtils.js # Utility functions
βββ array/ # Array problems
β βββ index.js # Array problem collection
β βββ _01.js # Problem definitions
β βββ _01_01.js # Test cases
β βββ ... # More problems
βββ string/ # String problems
βββ linked-lists/ # Linked list problems
βββ README.md # This file
- Reverse an Array/String - Basic array reversal
- Two Number Sum - Find pairs that sum to target
- Three Number Sum - Find triplets that sum to target
- Smallest Difference - Find smallest difference between two arrays
- Monotonic Array - Check if array is monotonic
- Spiral Traverse - Traverse 2D array in spiral order
- Longest Peak - Find longest peak in array
- Palindrome Check - Check if string is palindrome
- Longest Palindromic Substring - Find longest palindrome substring
- Longest Substring Without Repeating Characters - Find longest unique substring
- Remove Nth Node From End - Remove node from end of list
- Detect Cycle - Detect cycle in linked list
- Reverse Linked List - Reverse a linked list
- Read Carefully: Understand the input format and expected output
- Start Simple: Begin with basic approaches, then optimize
- Test Incrementally: Test your solution after each significant change
- Use the Error Information: Pay attention to the detailed failure information
- Don't Get Stuck: Use the skip option if you're struggling with a problem
- Create a new folder (e.g.,
trees/
) - Add problem files following the naming convention
- Update
runFile.js
to include the new category
Edit the topic
array in runFile.js
:
const topic = [
'array',
'string', // Uncomment to include string problems
'linkedList', // Uncomment to include linked list problems
]
Modify the maxAttempts
constant in runFile.js
:
const maxAttempts = 5; // Change from 3 to any number
"Error reloading solutions"
- Make sure
solution.js
has valid JavaScript syntax - Check that the
solve
function is properly exported
"Module not found"
- Ensure you're running the command from the correct directory
- Check that all files are present
Tests not updating
- Make sure you save
solution.js
after making changes - The system should automatically reload on each test run
-
Start the application:
node runFile.js
-
Read the problem:
Problem => Reverse an Array/String Input => [1, 4, 3, 2, 6, 5] Expected Output => [5, 6, 2, 3, 4, 1]
-
Write your solution in
solution.js
:function solve(arr) { return arr.reverse(); }
-
Test your solution:
- Type
r
and press Enter - See the results
- Iterate and improve until all tests pass!
This system is designed to help you practice DSA problems efficiently. Take your time, understand the problems, and enjoy the learning process!