This repository contains solutions to various technical interview problems implemented in JavaScript. Each problem is solved and tested to ensure correctness.
- Two Sums
- Max Consecutive Ones
- Longest Substring Without Repeating Characters
- Three Sums
- Valid Parentheses
- Valid Palindrome
- Winning Card
- Generate Sentence
- Sorted Squared
- Find First Non-Repeating Character Index
To run the tests for all problems, execute the following command:
npm run test
Feel free to explore each problem's solution and modify them as needed. Happy problem solving!
To debug the tests in the VSCode debugger, execute the following command: F5
.
This will open the test runner in debug mode, allowing you to step through the code and inspect the values of variables.
Contributions to this project are welcome! If you would like to contribute, please follow these steps:
- Fork the repository
- Create a new branch for your feature or bug fix
- Make your changes and ensure that the tests pass
- Commit your changes and push them to your forked repository (following the Semantic Release approach)
- Submit a pull request describing your changes
- Please make sure to follow the existing code style and provide a clear description of your changes. Your contribution will be reviewed, and once approved, it will be merged into the main repository.
/**
* Name of the Problem
* Short Description
*
* @dificulty Easy
* @example
* solution('input data') -> 'expected return'
*/
import { deepEqual } from 'node:assert'
import { describe, test } from 'node:test'
/**
* Time: O(n)
* Space: O(n)
* @param {String} str
* @returns {Boolean}
*/
function solution1(str) {
// Your code goes here
}
describe('Algorithm Name', () => {
test('should return correct values', () => {
const scenarios = [
['input', 'expected output'],
]
for (const [str, expected] of scenarios) {
deepEqual(solution1(str), expected)
}
})
})
In the above code snippet, you can see the structure of how to create a new algorithm from scratch.
- Replace "Name of the Problem" with the actual name of the problem.
- Write a short description of the problem.
- Provide an example of the function call and the expected return value.
- Implement the solution inside the solution1 function.
- Test your solution by adding test cases inside the describe block using the deepEqual function to compare the actual output with the expected output.
This template can be used as a starting point for solving new problems. Feel free to modify it according to the requirements of the problem you are working on.
This project is licensed under the MIT License.