Skip to content

sudheerj/datastructures-algorithms

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 

Repository files navigation

datastructures-algorithms

List of Programs related to data structures and algorithms

Data Structures

Stack

No. Name Source Live Documentation Level Pattern
1 Stack using array Source JavaScript - Easy Using Array operations
2 Stack using linkedlist Source JavaScript - Easy Using LinkedList operations

Queue

  1. Queue using array: JavaScript
  2. Queue using linkedlist: JavaScript

SinglyLinkedlist

  1. SinglyLinkedlist implementation: Source Playground Documentation

DoublyLinkedlist

  1. DoublyLinkedlist implementation: Source Playground Documentation

Tree

  1. Binary Search Tree: Source JavaScript Documentation

Graphs

  1. Unweighted undirected graph: Source Playground Documentation

HashTable

  1. HashTable: JavaScript

Algorithms

Array

No. Name Source Live Documentation Level Pattern
1 Contains duplicates Source Playground Documentation Easy Set/Object
2 Two sum2- Input array sorted Source Playground Documentation Medium Two pointers
3 3 sum Source Playground Documentation Medium Two pointers
4 Product of array except self Source Playground Documentation Medium Prefix and postfix pattern
5 Max sum subarray Source Playground Documentation Medium Kadane's algorithm
6 Minimum size subarray sum Source Playground Documentation Medium Sliding window
7 Sort Colors Source Playground Documentation Medium Two pointers
8 Maximum product subarray Source Playground Documentation Medium Kadane's algorithm
9 Find minimum in rotated sorted array Source Playground Documentation Medium Binary search technique
10 Maximum Circular subarray Source Playground Documentation Medium Kadane's algorithm
11 Rotate array Source Playground Documentation Medium Two pointers
12 Search in rotated sorted array Source Playground Documentation Medium Binary search
13 Container with most water Source Playground Documentation Medium Two pointers
14 First missing positive number Source JavaScript Documentation Hard In-place hashing
15 Best time to buy stock and sell stock Source JavaScript Documentation Easy Greedy algorithm
16 Two missing numbers Source JavaScript Documentation Medium Sum and average calculations
17 Pascal's Triangle Source JavaScript Documentation Easy Array traversal and sequential sum
18 Remove Element Source JavaScript Documentation Easy Array traversal
19 Can place flowers Source JavaScript Documentation Easy Array traversal and comparison
20 Majority Element Source JavaScript Documentation Easy Boyer Moore Voting algorithm
21 Pivot Index Source JavaScript Documentation Easy Array traversal
22 Range Sum queries Source JavaScript Documentation Easy Array traversal

String

No. Name Source Live Documentation Level Pattern
1 Longest substring without repeating characters Source JavaScript Documentation Medium Sliding Window
2 Longest repeating character replacement Source JavaScript Documentation Medium Sliding Window
3 Minimum window substring Source JavaScript Documentation Hard Sliding Window
4 Valid anagram Source JavaScript Documentation Easy Frequency counting
5 Group anagrams Source JavaScript Documentation Medium Frequency counting
6 Valid palindrome Source JavaScript Documentation Easy Two pointer
7 Longest palindromic substring Source JavaScript Documentation Medium Expanding around center
8 Palindromic substrings Source JavaScript Documentation Medium Expanding around center
9 Encode and decode strings Source JavaScript Documentation Medium Basic string and array operations
10 Greatest common devisor of strings Source JavaScript Documentation Easy Euclidean and String operations
11 Reverse words in string Source JavaScript Documentation Medium Basic string and array operations
12 Length of last word Source JavaScript Documentation Easy String traversal

Dynamic programming

No. Name Source Live Documentation Level Pattern
1 Climbing stairs Source JavaScript Documentation Medium Dynamic programming
2 Coin change Source JavaScript Documentation Medium Dynamic programming
3 Longest increasing subsequence Source JavaScript Documentation Medium Dynamic programming(Bottom up)
4 Longest common subsequence Source JavaScript Documentation Medium Two-dimentional bottom up Dynamic programming
5 Word break Source JavaScript Source Medium Bottom up dynamic programming
6 Combination Sum 4 Source JavaScript Documentation Medium Bottom up Dynamic programming
7 House robber Source JavaScript Documentation Medium Fibonacci pattern bottom-up dynamic programming
8 House robber 2 Source JavaScript Documentation Medium Bottom-up dynamic programming
9 Decode ways Source JavaScript Documentation Medium Dynamic programming
10 Unique paths Source JavaScript Documentation Medium Dynamic programming
11 Jump game Source JavaScript Documentation Medium Dynamic programming or Greedy

Binary

No. Name Source Playground Documentation Level Pattern
1 Sum of two integers Source JavaScript Documentation Medium Bitwise operations
2 Number of 1 Bits Source JavaScript Documentation Easy Brian Kernighans
3 Counting Bits Source JavaScript Documentation Easy Dynamic programming
4 Missing number Source JavaScript Documentation Easy Bitwise XOR
5 Reverse Bits Source JavaScript Documentation Easy Bitwise operations

Stack

No. Name Source Playground Documentation Level Pattern
1 Sort Stack Source JavaScript Documentation Easy Stack push & pop
2 Balanced Brackets Source JavaScript Documentation Medium Stack push and pop
3 Reverse Polish Notation Source JavaScript Documentation Medium Stack push & pop
4 Daily Temperatures Source JavaScript Documentation Medium Monotonic decreasing stack
5 Number of People See In Queue Source JavaScript Documentation Medium Monotonic decreasing stack

LinkedList

No. Name Source Playground Documentation Level Pattern
1 Reverse sublist Source JavaScript Documentation Easy List traversal
2 Detect cycle in a linkedlist Source Playground Documentation Easy Floyd's cycle-finding or Tortoise and Hare algorithm
3 Merge two sorted lists Source JavaScript Documentation Easy Arithmetic comparison
4 Merge K sorted lists Source JavaScript Documentation Hard Divide and conquer
5 Remove Kth node from end of list Source JavaScript Documentation Medium Two pointers
6 Reorder list Source Javascript Documentation Medium Two pointers
7 Find middle node Source JavaScript Documentation Easy Two pointers
8 Find Kth node from end of list Source JavaScript Documentation Easy Two pointers
9 Partition list Source JavaScript Documentation Medium Two pointers
10 Remove duplicates Source JavaScript Documentation Easy Two pointers
11 Binary to decimal Source JavaScript Documentation Easy List traversal and math operations

Doubly linkedlist

No. Name Source Playground Documentation Level Pattern
1 Swap first and last Source JavaScript Documentation Easy Swap nodes
2 Palindrome check Source Playground Documentation Easy Two pointers
3 Swap node pairs Source JavaScript Documentation Medium List traversal and update pointers

Tree

No. Name Source Playground Documentation Level Pattern
1 Maximum depth of binary tree Source JavaScript Documentation Easy Depth First Search(DFS) with recursion
2 Same tree Source JavaScript Documentation Easy Depth First Search(DFS) with recursion
3 Invert or Flip binary tree Source JavaScript Documentation Easy Swapping nodes and Depth First Search(DFS) with recursion
4 Binary tree maximum path sum Source JavaScript Documentation Hard DFS using recursion
5 Binary tree level order traversal Source JavaScript Documentation Easy Depth First Search(DFS) with recursion
6 Serialize and deserialize binary tree Source JavaScript Documentation Hard DFS preorder traversal
7 Subtree of another tree Source JavaScript Documentation Easy Depth First Search(DFS) with recursion
8 Construct binary tree from preorder and inorder traversal Source JavaScript Documentation Medium DFS with recursion
9 Validate BST Source JavaScript Documentation Medium Depth-First-Search(DFS) using recursion
10 Kth smallest element in BST Source JavaScript Documentation Medium Iterative inorder traversal using stack
11 Lowest Common Ancestor of BST Source JavaScript Documentation Medium Iterative tree traversal
12 Trie Source JavaScript Documentation Medium Iteration over string characters
13 Design and Search words Datastructure Source JavaScript Documentation Medium Trie and DFS recursion
14 Word search 2 Source JavaScript Documentation Hard Backtracking with Trie

Graph

No. Name Source Live Documentation Level Pattern
1 Clone graph Source JavaScript Documentation Medium Depth-First-Search(DFS) using recursion
2 Course schedule Source JavaScript Documentation Medium DFS using recursion
3 Pacific Atlantic waterflow Source Playground Documentation Medium DFS using recursion
4 Number of Islands Source JavaScript Documentation Medium DFS using recursion
5 Alien dictionary Source JavaScript Documentation Hard Kahn's algorithm for topological sorting
6 Graph valid tree Source JavaScript Documentation Medium Union Find algorithm(+ union by rank & path compression)
7 Number of connected components in an undirected graph Source JavaScript Documentation Medium Union Find algorithm(+ union by rank & path compression)
8 Walls and gates Source JavaScript Documentation Medium BFS traversal

Matrix

No. Name Source Live Documentation Level Pattern
1 Set matrix zeros Source JavaScript Documentation Medium In-place updates through traversal
2. Spiral matrix Source JavaScript Documentation Medium Boundary matrix traversal/spiral pattern
3 Rotate image Source JavaScript Documentation Medium Inplace square rotation
4 Word search Source JavaScript Documentation Medium Depth-First Search (DFS) using recursion

Interval

No. Name Source Live Documentation Level Pattern
1 Insert interval Source JavaScript Documentation Medium Basic math operations
2 Merge interval Source JavaScript Documentation Medium Sorting and basic math operations
3 Non-overlapping intervals Source JavaScript Documentation Medium Greedy and basic math operations
4 Meeting rooms Source JavaScript Documentation Medium Greedy and basic math operations
5 Meeting rooms 2 Source JavaScript Documentation Medium Two pointers

Hashtable

No. Name Source Live Documentation Level Pattern
1 Duplicates Source JavaScript JavaScript Easy Using Map
2 Two sum Source JavaScript Documentation Easy Using Map
3 First non repeating character Source JavaScript Documentation Easy Using Map
4 Group anagrams Source JavaScript Documentation Medium Using Map & its methods
5 Verify Common Elements Source JavaScript Documentation Easy Using Map methods
6 Longest consequtive sequence Source JavaScript Documentation Medium Find sequence using set or hash table
7 Valid Sudoku Source JavaScript Documentation Medium Using Map and Set methods
8 Letter combinations Source JavaScript Documentation Medium Backtracking with hash table mapping
9 LRU Cache Source JavaScript Documentation Medium Combination of Hash Table and doubly linked list
10 Maximum number of balloons Source JavaScript Documentation Easy Hash map on characters
11 Isomorphic Strings Source JavaScript Documentation Easy mapping characters using Hash maps

Sorting

No. Name Source Playground Documentation Level Complexity
1 Bubble sort Source JavaScript Documentation Easy TC: O(n2), SC: O(1)
2 Selection sort Source JavaScript Documentation Easy TC: O(n2), SC: O(1)
3 Insertion sort Source JavaScript Documentation Easy TC: O(n2), SC: O(1)
4 Merge sort Source JavaScript Documentation Medium TC: O(n log(n)), SC: O(n)
5 Quick sort Source JavaScript Documentation Medium TC: O(n2), SC: O(log n)
6 Heap sort Source JavaScript Documentation Hard TC: O(n log(n)), SC: O(1)