Skip to content

A template for solving DSA problems in JavaScript with tests and structure.

Notifications You must be signed in to change notification settings

juan-carlos-correa/dsa-javascript

Repository files navigation

📄 New here? 👉 See how to use this template →

🧠 [EXERCISE TITLE HERE]

A quick one-liner describing the problem.
Example: Check if two strings are anagrams.

✍️ Your Task

Your goal is to solve the coding challenge using a clear and efficient solution.

  1. Read the problem and input/output requirements
  2. Implement your solution in src/main.mjs
  3. Run tests with npm run test to validate your solution

📘 Description

Describe the problem in detail.

Example:

Given two strings s1 and s2, return true if s2 is an anagram of s1, and false otherwise.

An anagram is a word or phrase formed by rearranging the letters of a different word.

📥 Input

  • s1: a string (1 ≤ s1.length ≤ 10⁵)
  • s2: a string (1 ≤ s2.length ≤ 10⁵)
  • No spaces, only lowercase letters

📤 Output

  • Returns true or false

🛠️ Instructions

  1. Open the file src/main.mjs and implement the solution.
  2. To verify your solution, run the tests in src/main.test.js using:
npm run test

✅ Do not modify the test file unless you’re adding extra edge cases.

💡 Tips

You can add any tips or hints that might help the user solve the problem.

For example:

  • Use .toLowerCase() if needed
  • Use objects, arrays or Map to count character frequencies
  • Aim for O(n) time complexity if possible
  • Compare frequency maps or use one-pass counter

🧪 Run Tests

This repo uses Vitest. To run tests locally:

npm install
npm run test

✅ Make sure your implementation is in src/main.mjs and your tests in src/main.test.js.

Happy coding! 🚀

About

A template for solving DSA problems in JavaScript with tests and structure.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published