Welcome! This repository is a personal and growing collection of essential Data Structures and Algorithms (DSA) problems, all implemented in JavaScript.
The goal here isn't to solve every problem under the sun. Instead, this repository follows the 80/20 principle: focusing on the critical 20% of DSA patterns and problems that provide 80% of the value for interviews and building a strong programming foundation.
This repository is also a documentation of my personal growth. I will be improving the solutions and adding new problems as I learn. My hope is that this living document can serve as a straightforward, no-fluff resource for anyone looking to get started or brush up on their DSA skills in JavaScript.
- Clone the repository:
git clone https://github.com/your-username/DSA-in-Javascript.git
- Navigate to a problem: The problems are organized by common coding patterns.
- Try it yourself: Before looking at the solution, try to code it up on your own.
- Review and learn: Compare your solution with the one provided. The code includes comments to explain the logic and approach.
The problems are organized by the pattern they represent. This helps in recognizing which tool to use when you encounter a new problem.
/Patterns
└── /<Pattern-Name>
└── <Problem-Name>.js
- 4Sum II
- Contains Duplicate
- Group Anagrams
- Intersection of Two Arrays II
- Jewels and Stones
- Longest Consecutive Sequence
- Ransom Note
- Single Number
- Top K Frequent Elements
- Two Sum
- Valid Anagram
- (no files yet)
- Add Two Numbers
- Cycle Detection in a Linked List
- Merge Two Sorted Lists
- Palindrome Linked List
- Remove Nth Node From End of List
- Reverse a Linked List
- Reorder List
- Copy List with Random Pointer
- Merge k Sorted Lists
- Find Pivot Index
- Find the Highest Altitude
- Maximum Subarray
- Product of Array Except Self
- Range Sum Query - Immutable
- Range Sum Query 2D - Immutable
- Subarray Sum Equals K
- Find the Smallest Subarray with a Given Sum
- Longest Substring with At Most Two Distinct Characters
- Longest Substring with K Distinct Characters
- Longest Substring with Same Letters After Replacement
- Longest Substring Without Repeating Characters
- max consecutive ones III
- Maximum Average Subarray I
- Maximum Number of Vowels in a Substring of Given Length
- Maximum Sum Subarray of Size K
- Minimum Window Substring
- Permutation in a String
- Longest Subarray of 1's After Deleting One Element
- 3Sum
- Container With Most Water
- Is Subsequence
- Max Number of K-Sum Pairs
- Move Zeros
- Remove Duplicates
- Reverse Vowels of a String
- Squares of a Sorted Array
- Two Sum
- Valid Palindrome
While this is a personal project, feedback and suggestions are always welcome! If you see a way to improve a solution or want to suggest a "must-know" problem, feel free to open an issue or a pull request.
If you'd like, I can:
- Add missing problem files to any pattern folder in the repo format.
- Generate a template for new problems that matches the repository style.
- Link specific functions or symbols to their implementations (e.g.
findPermutation)