Coder Social home page Coder Social logo

sherxon / algods Goto Github PK

View Code? Open in Web Editor NEW
3.4K 168.0 607.0 1.55 MB

Implementation of Algorithms and Data Structures, Problems and Solutions

Home Page: http://sherxon.com

License: MIT License

Java 100.00%
interview-questions bst algorithms sort data-structrues java graph-algorithms binary-search-tree linked-list dfs mergesort sorting-algorithms search-algorithm dynamic-programming dijkstra shortest-paths

algods's Introduction

English | 简体中文

Algorithms and Data Structures

This is the collection of Algorithms, Data Structures and Interview Questions with solutions. This repository contains my solutions for common algorithmic problems and implementation of Data Structures in Java. I've created this repository to learn about algorithms. I am adding solutions continuously.

Algorithms, Data Structures and more than 300 Problems and Solutions are provided so far.

Questions

Here are questions divided by difficulty level:

  1. Easy Questions and Answers
  2. Medium Questions and Answers
  3. Hard Questions and Answers

Problems:

Arrays

  1. Rotate Array
  2. Contains Duplicate
  3. Find Peak Element
  4. Maximum Subarray
  5. Kth Largest Element in an Array
  6. Find All Duplicates in an Array
  7. Longest Increasing Subsequence
  8. Rotate Image, matrix
  9. Shuffle an Array
  10. Find Min in Rotated Array
  11. Search in Rotated Array

Linked List

  1. Singly Linked List Implementation
  2. Doubly Linked List Implementation
  3. Delete Node in a Linked List
  4. Palindrome Linked List
  5. Reverse Linked List
  6. Intersection of Two Linked Lists
  7. Linked List Cycle
  8. Remove Nth Node From End of List
  9. Merge Sort List
  10. Find Linked List Cycle
  11. Merge k Sorted Lists
    And many other Linked list problems

Binary Tree

  1. Binary Tree Level Order Traversal
  2. Sum of Left Leaves
  3. Invert Binary Tree
  4. Binary Search Tree Iterator
  5. Binary Tree Postorder Traversal
  6. Binary Tree Preorder Traversal
  7. Flatten Binary Tree to Linked List
  8. Symmetric Tree
  9. Binary Tree Inorder Traversal
  10. Same Tree
  11. Maximum Depth of Binary Tree
  12. Balanced Binary Tree
  13. Minimum Depth of Binary Tree
  14. Sorted List to Balanced Binary Search Tree
  15. Validate Binary Search Tree
  16. Sorted List to Balanced BST
  17. Kth Smallest Element in a BST
  18. Binary Tree Zigzag Level Order Traversal
  19. Delete Node in a BST
  20. Lowest Common Ancestor of BST
  21. Binary Tree Left Side View
  22. Binary Tree Right Side View
  23. Mode in BST
  24. Most Frequent Subtree Sum
  25. Find Largest Element in Each Row
  26. Serialize and Deserialize BT
    And many other tree problems

Math

  1. Integer Break
  2. Reverse Bits
  3. Palindrome Number
  4. Math.pow
  5. Jug and Water Problem
  6. Sieve of Eratosthenes
  7. Fermat's primality
  8. Evaluate Reverse Polish Notation

Stack & Queue

  1. Min Stack
  2. Min Queue
  3. Implement Stack Using Queue
  4. Implement Queue Using Stack
  5. Sort Stack

Dynamic Programming

  1. Fibonacci Numbers
  2. Word Break
  3. Subset Sum
  4. 0/1 Knapsack Problem
  5. Shortest Palindrome (KMP)
  6. Minimum Square Sum
  7. Maximum weight transformation of a String
  8. Coin Change

Misc

  1. Union Find
  2. Permutations
  3. Subsets

Algorithms

Sorting And Searching

  1. Bubble Sort
  2. Insertion Sort
  3. Selection Sort
  4. Counting Sort
  5. Binary Search , Lower & Upper Bounds
  6. MergeSort
  7. QuickSort

Graphs

  1. Breadth First Search (BFS)
  2. Depth First Search (DFS)
  3. Prim's Minimum Spanning Tree (MST)
  4. KrusKal's Minimum Spanning Tree (MST)
  5. Topological Sorting
  6. Shortest Path Dijsktra
  7. Shortest Path Bellman-Ford
  8. A* Heuristic Path Finding
  9. Is Graph Bipartite
  10. Is Graph Connected
  11. Cycle Detection
  12. Undirected Graph Bridge Detection

String

  1. Rabin Karp Subsequence search
  2. Ransom Note
  3. Reverse String
  4. Longest Common Prefix
  5. Is Anagram
  6. Needle and Haystack
  7. Word Break
  8. Meta Strings

Data Structure:

Trees

  1. Binary Search Tree (recursive)
  2. Binary Search Tree (iterative)
  3. AVL Tree
  4. Trie (Prefix tree)
  5. Hashed Array Tree
  6. LRU Cache

Contribute

Did you find a bug? Any way to do it better? Please feel free to pull-request it. :)

algods's People

Contributors

sherxon avatar piyush-pawar-17 avatar prafful1 avatar yunshuipiao avatar rajatsharma23 avatar jwilk avatar fredrikmeyer avatar rahulkavale avatar vcharmcaster avatar al0mie avatar vineet1020 avatar

Stargazers

Misho avatar Triet Trinh avatar  avatar The Sugar Glider avatar Vinicius Dos Santos Mota avatar  avatar Jeetesh Saini avatar waskito shidiq avatar Logan Chow avatar Backwoods Bob avatar Mahesh Bishnoi avatar  avatar Dmytro Zadorozhnii avatar  avatar 王涛 avatar  avatar Irvan Fauziansyah avatar Parag Gajbhiye avatar Jack Crosby avatar  avatar teksturepako avatar Arjun Ivor Kukreja avatar  avatar Abhijit kumar  avatar  avatar Kunal Gautam avatar Firdavs Khaydar avatar Marcin Krzyzanowski avatar Aman Singh avatar 1A7V9A avatar Dritan Xhezo avatar shiwani thagele avatar  avatar Rick Cochrane avatar Karthik avatar Dimas Ananda Pamungkas avatar Luann Francisco avatar Milad Arabi avatar  avatar Sai Krishna avatar  avatar PRATHYUSHA VELUPULA avatar  avatar  avatar Stan Soo avatar Mai Elkheshen avatar Taketoday avatar PradeepKP avatar Patrick Fares avatar  avatar Alisher Khayrullaev avatar 梦里不知身是客 avatar 张先森-加勒比海带 avatar Avalon avatar  avatar kktt007 avatar loveFluffy avatar DMITRII BOGDANOV avatar Dilshod avatar Javlon Ergashev avatar  avatar Akbar avatar KamalkaNipun avatar BakhodirovCodes avatar Michael Scott Hertzberg avatar Miguel Valle Durand avatar xufengfeng avatar Marwa avatar Diana Vintila avatar Meir avatar Tetteh Kodjo-Sarso avatar mito avatar Saurabh Daware avatar Gadde Jaswanth avatar  avatar Abdulaziz Sirojiddinov avatar Chris avatar Sebastian L. Corporan avatar Tien Vu avatar Trey Perry avatar Suvraneel _Saha avatar Santa Paradin avatar Lohitha avatar  avatar Tom Bushell avatar Buddha Saikia avatar  avatar Aditya Bhagavatula avatar Taimoor Javed avatar Xiaoming Liu avatar Ibrokhim Turdiev avatar Ajay Kumar S N avatar Luoji avatar nguyen chi cuong avatar o'Laoxu avatar  avatar Jean-Philippe Prost avatar Kudratkhuja Musaev avatar  avatar Uladzislava Ryzhova avatar

Watchers

Mike avatar Binh Nguyen avatar Rifqi Alfian avatar  avatar Jon Howard avatar Marcelo Sa avatar Carl Desautels avatar Tom Romano avatar Jaeyoung, Choi avatar Raul Martinez Jr avatar ziming avatar dikshie avatar Daniel Drozdzewski avatar hamlet avatar Kaique Silva avatar Anastasiia Kornilova avatar Zhuochun avatar Shinn Lok avatar Eric avatar  avatar gkvikram avatar lijunjie avatar  avatar lostoy avatar Sarvar Abdullaev avatar Tom Green avatar Len Cao avatar changliwei avatar maksudul avatar Victor Login avatar Jorge Cañas avatar  avatar Charlie avatar ruffy gao avatar ming_qian avatar Abdujabbar Mirkhalikov avatar  avatar  avatar  avatar Jeff O avatar  avatar 梁植华 avatar xied5531 avatar Arshaan Qureshi avatar Tadjibaev Ulugbek avatar hc.chen avatar Stan avatar o'Laoxu avatar Oleksii Lysenko avatar Gaurav Gupta avatar roc avatar VW avatar tomato avatar huliyou avatar Shishram Karwal avatar  avatar Kasthuri raman avatar Tanmoy Majumdar avatar  avatar  avatar  avatar jaupaj avatar  avatar Ares Ai avatar RajDesai avatar  avatar Arunkumar Venkataramanan avatar  avatar Henry Nguyen avatar John Ng avatar Jon Jones avatar Justin Tuchek avatar Yugal Yadav avatar  avatar Nilesh Gunjan avatar Tesfay Aregay avatar Keyser Söze avatar  avatar Chris J avatar Kai avatar HudsonShi avatar JellyFish avatar David avatar caocao485 avatar oyyj avatar charnix avatar Oleksandr B. avatar neo avatar Mehmet Öner Yalçın avatar  avatar Michael D avatar C Martin avatar  avatar Ravi Singh avatar Basi avatar  avatar Mingkun Yang avatar  avatar Deepa avatar 32@revolution avatar

algods's Issues

Another approach to Math.abs()

hi I like your code for ReverseInteger. Why do you use the Math.abs()? Here is another approach with less code:

public int reverse(int x) {
    int rev = 0;
    while(x != 0){
        rev = rev*10 + x%10;
        x = x/10;
    }
 
    return rev;
}

CycleDetection

Whether or not there is a cycle, this program always returns true after running
` for (Integer neighbor : graph.getNeighbors(start)) {

        if(visited.contains(neighbor) && !exited.contains(neighbor)) return true;

        if(!visited.contains(neighbor) && dfs(neighbor)) return true;
    }`

CycleDetection

Looks like CycleDetection will fail if Graph has multiple component.

Fibonacci using matrix multiplication

Hello.
I'm not fluent in Java so I won't implement it by myself, however there is an O(log n) solution for finding nth Fibonacci number which is based on matrix exponentiation -

[[1 1] [1 0]]^n = [[F_{n+1} F_n] [F_n F_{n-1}]]

This can be done with exponentiation by squaring which is O(log n).

Bloom filter

It would be really cool to have Bloom Filter.

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.