Coder Social home page Coder Social logo

sudheerj / datastructures-algorithms Goto Github PK

View Code? Open in Web Editor NEW
577.0 7.0 169.0 1.72 MB

List of Programs related to data structures and algorithms

Java 56.37% JavaScript 42.39% Go 0.76% TypeScript 0.48%
datastructures-algorithms datastructures algorithms java javascript algorithm-challenges interview leetcode dsa dsa-algorithm lodash prototype linkedlist polyfills dynamic-programming graph queue stack tree

datastructures-algorithms's Introduction

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
23 Disappeared numbers Source JavaScript Documentation Easy Array traversal
24 Identical pairs Source JavaScript Documentation Easy Array traversal & map
25 Destination City Source JavaScript Documentation Easy Array traversal & set
26 Set mismatch Source JavaScript Documentation Easy Array traversal & marking numbers
27 Intersection of arrays Source JavaScript Documentation Easy Set and array traversal
29 Special array Source JavaScript Documentation Easy Frequency counter and 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
14 First unique character Source JavaScript Documentation Easy Hashing for character count

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)

datastructures-algorithms's People

Contributors

sudheerj avatar mademoiselle-chantal avatar writetosurya avatar

Stargazers

 avatar Paolo Joseph avatar Md. Abu Nasib avatar Vamshi krishna avatar Andrew Huynh avatar SAHIL PURKAIT avatar  avatar Monika Maurya avatar Amir Elkased avatar Abdulbaki avatar Jim avatar Yuvraj Karna avatar  avatar shivansh verma avatar Abdul Maajid avatar  avatar Sanket Khardekar avatar Siarhei Yarutsich avatar Agathiyan S avatar Shreyas Mulay avatar Ali  avatar  avatar Mruthunjay avatar Reese Wellin avatar Jaishree Singh avatar Rakshith avatar Omar Mandour avatar Tiago Celestino avatar Eduardo Zaqueu avatar Aritra avatar Yumi Patton avatar 야쿠프 avatar Abdulali Noori avatar Daaimah Tibrey avatar Something Awful avatar Rhys E avatar Sadman Sakib avatar  avatar Iglyson Silva avatar Dewashish Gope avatar Yelyzaveta Taran avatar Manthan Bhosle avatar Nis avatar Sam avatar Shuva Paul avatar Aref Shojaei avatar William Wu avatar  avatar Om Limdiwala avatar Md.Atikul Islam shuvo avatar VNHZero avatar Dinesh Dhayfule avatar Abishek avatar NaveenKumar avatar Bipin M V avatar Rashaun Bennett avatar  avatar Nabed Khan avatar Pranjal Kuhikar avatar  avatar  avatar Vedangi Thombare avatar iukkeopaa avatar mahdi delnavazi avatar Hrushikesh TK avatar  avatar Amir Jani avatar  avatar Muhtasim Billah Ratul avatar  avatar Orestes Garcia avatar Ravi Shankar avatar Ahmed Rabie G avatar Tejas Karade avatar Zain Ahmed avatar Himanshu tamoli avatar Paras Sakarwal avatar Ansh Sharma avatar SAI PRATHAM avatar Dipto Karmaker avatar Tori Choudhury avatar Harshal Deshattiwar avatar Bharat Dua avatar Kiran M avatar Mary Richelle avatar Naresh Vasuja avatar Faiz Alam avatar Dhayanandhan Raju avatar ISMAIL KHAN avatar Shahadath Hossen Sajib avatar Tejas Patil avatar Kuldeep Mehar avatar  avatar Liju Thomas avatar Aman Shrivastava avatar denismatvieiev avatar George Koubbe avatar Vaishnav avatar Raj Rathore avatar Tom Rytt avatar

Watchers

 avatar clement selva prasath berkmans avatar Shubham Prakash Jha avatar Naveen Chandra B avatar  avatar VAMSI KRISHNA PEDDAPUDI avatar Steffy John avatar

datastructures-algorithms's Issues

Typo in the README.md

Description

As l was reading through the README, l came across the typo "Strctures".

Screenshot 2024-05-28 at 08 16 52

[bug] Binary Search Tree unreachable code

Problem is unnecessary returns after while loops.

    insert(value) {
        const newNode = new Node(value);
        if(this.root === null) {
            this.root = newNode;
            return this;
        } 
            let currentNode = this.root;
            while(true) {
                if(value < currentNode.value) {
                    // Left
                    if(currentNode.left ===  null) {
                        currentNode.left = newNode;
                        return this;
                    }
                    currentNode = currentNode.left
                } else if (value > currentNode.right){
                    // Right
                    if(currentNode.right === null) {
                        currentNode.right = newNode;
                        return this;
                    }
                    currentNode = currentNode.right;
                }  else {
                    return this;
                }
            }
        return this; // I think this is unreachable -> once inside the while loop, execution won't leave that code block
    }

I think this same mistake is repeated in the lookup function where you return false after another while loop.

Code Playgrounds

Great work. Thank you!

I suggest adding playgrounds to allow trying out code, similar to TheAlgorithms website, which uses LiveCodes (see example).

Please allow me to introduce LiveCodes, a feature-rich, open-source, client-side, code playground that supports 80+ languages and frameworks, including JS, TS, React, Vue, Svelte, Solid, Python, Go, Ruby, PHP and others (see starter templates). The announcement post gives a general overview.

Projects can be shared, exported and deployed (to GitHub Pages). Code can be imported from many sources including GitHub.

LiveCodes is very configurable. Many of the features can be configured by query parameters

For example, to load the bubble sort algorithm from this URL:

https://github.com/sudheerj/datastructures-algorithms/blob/master/src/javascript/algorithms/sorting/bubbleSortLinkedlist.js

Add it to the query parameter x like that, (also have the console open):

https://livecodes.io/?console=open&x=https://github.com/sudheerj/datastructures-algorithms/blob/master/src/javascript/algorithms/sorting/bubbleSortLinkedlist.js

open in LiveCodes

Screenshot:

image

You may want, for example, to add links to the algorithms in the repo README like that:


Bubble Sort: implementation - playground


LiveCodes also allows running automated tests (using Jest). This feature is used by TheAlgorithms website to validate the algorithms implementation.

Playgrounds can also be embedded in any webpage, using a powerful, yet easy-to-use, SDK.

Comprehensive documentations are available with live demos, code samples and screenshots.

LiveCodes is free with unlimited usage, no ads and no account required. It can be easily self-hosted (if you want), and can be used for commercial projects (MIT license).

Disclosure: obviously, I'm the author of LiveCodes.

If you feel this can be useful, I can help getting started with providing playgrounds for the code in this repo or for other projects.

I thought you would be interested. Otherwise, please feel free to close this.
Thank you.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.