Skip to content

This repository is a collection of coding problems organized by Data Structures and Algorithms (DSA) topics. Each problem includes a clear explanation, JavaScript implementation, and notes on which data structure is being used and why.

Notifications You must be signed in to change notification settings

PallaviDule/DSA-specific

Repository files navigation

DSA Practice

Welcome!
This repository is a collection of coding problems organized by Data Structures and Algorithms (DSA) topics. Each problem includes a clear explanation, JavaScript implementation, and notes on which data structure is being used and why.

Whether I’m revisiting core concepts, preparing for upcoming interviews, or just enjoying solving problems — this repo helps me keep everything organized, easy to refer back to, and ready to expand as I go.
Each problem folder includes:

  • A clear README.md with the problem statement, approach, and edge cases
  • The solution.js file with a working implementation

Categories

Great point — here's an improved version of the table with a note in the "Reference Docs" column indicating that the link points to built-in methods or concept documentation, so it's clear why it's useful before diving into problems:

Category Path Reference Docs (In-built Methods / Concepts)
Arrays arrays/ Array Methods – MDN
Trees trees/ Tree – GFG (Concept)
Map map/ Map Methods – MDN
Strings strings/ String Methods – MDN
Linked Lists linked-lists/ Linked List – GFG (Concept)
Stacks & Queues stacks-queues/ (coming soon) Stack & Queue – GFG (Concept)
Math basic-math/ Math - MDN

How to Use

  • Each folder has a README.md explaining the problem, thought process, and solution.
  • How To Run:
    • Directly run any .js file with Node.js to test the solution:
      • Example: node array/easy/001-two-sum/solution.js
    • Run using the central index.js to easily execute problems by their keys:
      • Run the following command with the desired problem key:node index.js ${problemKey} or npm start ${problemKey}
        • You can find the problem key for each problem in the main table.
        • Example: To run the Two Sum solution, use the following command:node index.js twoSum or npm start twoSum

75 Sample Problems (Grouped by Category)

Math / Basic Algorithm

Problem No. Title Path/ProblemKey Difficulty
001 Fizz Buzz fizzBuzz Easy
002 Number of Steps to Reduce a Number to Zero numberOfSteps Easy
003 Palindrome palindromeNumber Easy
004 Roman to Integer romanToInteger Easy
005 Plus One plusOne Easy (array)
006 Square root squareRoot Easy (array, binary search)
007 Fibbonacci Number fibbonacciNumber Easy (Dynamic Programming, Recursion, Memoization)
008 Climb stairs climbStairs Easy (Dynamic Programming, Memoization)
009 Sum of Digits sumOfDigits Easy (Basic Math)
010 Power(x,n) xRaisedToPowerN Medium
011 Count Primes countPrimes Medium (Sieve of Eratosthenes)
012 Reverse Integer reverseInteger Medium
013 Sum of Integer (without + ,-) sumIntegerWithoutPlusMinus Medium

Array

Problem No. Title Path/Problem Key Difficulty
001 Two Sum twoSum Easy
002 Richest customer wealth richestCustomerWealth Easy
003 Sum of 1-D array sumOf1dArray Easy
004 Median of Two Sorted Arrays medianOfTwoSortedArray Hard
005 Median of Two Sorted Arrays medianOfTwoSortedArrayMergeSort Hard
006 Remove Duplicate from sorted arrays removeDuplicates Easy (two pointer)
007 Remove Element from array removeElement Easy (two pointer)
008 Merge two sorted array mergeTwoSortedArray Easy (two pointer, sorting)
009 Pascal Triangle generatePascalTriangle Easy (Dynamic Programming)
009 Pascal Triangle II nthRowOfPascalTriangle Easy (Dynamic Programming)
010 Best time to sell stock bestTimeToSellStock Easy (Dynamic Programming)
011 Two Sum II twoSumII Medium (two pointer, binary search)
012 Container With Most Water containerWithMostWater Medium (two pointers, greedy)
013 Intersection of two arrays intersectionOfTwoArrays Easy
013 Move Zeros moveZeros Easy (two pointer)
014 Max Sum Of Sub Array maxSumOfSubArray Medium (two pointer)
015 Majority Element majorityElement Easy (Hash Table, Divide and Conquer ,Sorting, kadane's Algo)
016 Search in Rotated Sorted Array searchInRotatedSortedArray Medium (Binary Search)
017 Peak Index In Mountain Array peakIndexInMountainArray Medium (Binary Search)
018 Product except self productExceptSelf Medium (Binary Search)
019 Single Element in a Sorted Array singleNonDuplicate Medium (Binary Search)
020 Allocate Minimum Pages allocateMinimumPages Medium (Searching, Divide and Conquer, Binary Search)
021 Painter's Partition paintersPartition Medium (Searching, Divide and Conquer, Binary Search, GFG)
022 Aggressice Cows aggressiveCows Medium (Searching, Divide and Conquer, Binary Search, spoj)
023 Sort Colors sortColors Medium ( three pointers, leetcode, Dutch National Flag)
024 Next Permutation nextPermutation Medium ( two pointers, leetcode)
025 Minimum In Rotated Sorted Array minimumInRotatedSortedArray Medium (binary search, leetcode, pivot detection)
026 GCD of Array gcdOfArray Easy (leetcode, Math)
027 Row with maximum sum in a Matrix rowWithMaxSumInMatrix Easy (gfg, Math)
028 Column with maximum sum in a Matrix colWithMaxSumInMatrix Easy (gfg, Math)
029 Matrix Diagonal Sum matrixDiagonalsSum Easy (leetcode, Math)
030 Search in 2D matrix searchIn2dMatrix Medium (matrix, binary)
031 Search in 2D matrix II searchIn2dMatrix Medium (matrix, binary)
032 spiral matrix spiralMatrix Medium (matrix, simulation)
032 spiral matrix II spiralMatrixII Medium (matrix, simulation)
033 3 Sum threeSum Medium (two pointers, sorting)
034 4 Sum fourSum Medium (two pointers, sorting)
035 Subsets subsets Medium (backtracking)

Map

Problem No. Title Path/Problem Key Difficulty
001 Ransom Note ransomNote easy
002 Unique Number of Occurrences uniqueOccurrences easy (Set)

String

Problem No. Title Path/Problem Key Difficulty
001 Longest substring without duplicates longestSubstringNoDuplicate Medium
002 Longest common prefix longestCommonPrefix Easy
003 Find the Index of the First Occurrence in a String indexOfFirstOccurrence Easy
004 Length of Last Word lengthOfLastWord Easy (Two-pointer)
005 Add Binary addBinary Easy (Math, Bit Manipulation, Simulation)
006 Reverse String reverseString Easy (Two-pointer)
007 Valid Palindrome validPalindrome Easy (Two-pointer)
008 Remove All Occurrences of a Substring removeOccurrencesOfSubstring Medium (Stack, Simulation)
009 Permutation in String permutationInString Medium (Hash Table, Two Pointers, Sliding Window)
010 Reverse the Words in String reverseWordsInString Medium (Two Pointers)
011 String Compression stringCompression Medium (Two Pointers, in-place)

Set

Problem No. Title Path/Problem Key Difficulty
001 Longest substring without duplicates longestSubstringNoDuplicateSet Medium

Stack

Problem No. Title Path/Problem Key Difficulty
001 Valid Parentheses validParentheses Easy
002 132 pattern OneThreeTwoPattern Medium, Array, Binary Search, Stack, Monotonic Stack

Tree

Problem No. Title Path/Problem Key Difficulty
001 Root Node Sum Check rootEqualsSum Easy

Linked List

Problem No. Title Path/Problem Key Difficulty
001 Middle of linked list middleNode Easy
002 Add two numbers addTwoLinkedListNumber Medium
003 Merge two sorted List mergeTwoSortedLinkedList Easy
004 Delete Duplicates deleteDuplicates Easy
005 LinkedList methods runLinkedListMethods Easy

Cheatsheet

image

Work in Progress

This is an evolving repository as I solve more problems.
Feel free to explore, learn, and suggest improvements!

Happy Coding! 🚀

About

This repository is a collection of coding problems organized by Data Structures and Algorithms (DSA) topics. Each problem includes a clear explanation, JavaScript implementation, and notes on which data structure is being used and why.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published