Data Structures

Linear

  • Array
  • Linked List
  • Queue
  • Stack

Non-Linear

  • Tree
  • Graph
Algorithm

Sort

Search

  • Linear Search
  • Binary Search

Tree Traversal

  • In Order
  • Pre Order
  • Post Order

Graph

  • DFS / BFS
  • Shortest Path
  • Minimum Spanning Tree
Techniques

  • Two Pointer
  • Sliding Window
  • Fast and Slow Pointer
  • Prefix Sum
  • Top 'K' Elements
  • Divide and Conquer
  • Recursion
  • Backtracking
  • Dynamic Programming

    • Memoization
    • Tabulation
  • Greedy

Recursion

Recursive algorithms provide a powerful framework for solving problems by breaking them down into smaller, self-similar subproblems. By focusing on the decomposition process and understanding how to express solutions recursively, you'll gain a deeper understanding of algorithmic design principles that can be applied to a wide range of problems.

  1. Arrange balls

  2. Find Binomial coefficient

  3. Find Nth Catalan Number

  4. Climbing stairs with 3 moves

  5. Climbing stairs

  6. Find minimum coins to make change

  7. Find number of way to make coin change

  8. Find all subsequence combinations of a string

  9. Count number of derangements

  10. Find all distinct subset sums of an array

  11. Find Nth Fibonacci number

  12. House robber

  13. Find minimum of jumps to reach end

  14. 0/1 Knapsack problem

  15. Unbounded knapsack

  16. Longest common increasing subsequence (LCS + LIS)

  17. Find longest common subsequence (LCS)

  18. Find longest common substring

  19. Find longest increasing subsequence (LIS)

  20. Longest palindromic subsequence (LPS)

  21. Maximum size of square sub-matrix with all 1s

  22. Min cost path

  23. Minimum insertions to form a palindrome

  24. Find the minimum number of edits

  25. Number of unique BST with N keys

  26. Maximize number segments of cutted in length x, y and z

  27. Find number of ways paint a fence with n posts and k colors

  28. Partition a set into two subsets of equal sum

  29. Pascal's Triangle

  30. Regular expression wildcard pattern matching

  31. Find number of permutation with K inversions

  32. Print maximum number of A’s using given four keys

  33. Stacking box

  34. Subsequence with difference of 1

  35. Subset sum

  36. Maximize total tips

  37. Find Nth Tribonacci number

  38. Count unique paths in matrix from top left to bottom right

  39. Weighted interval job scheduling

  40. Word Break

Backtracking

A backtracking algorithm tries to construct a solution to a computational problem incrementally, one small piece at a time. Whenever the algorithm needs to decide between multiple alternatives to the next component of the solution, it recursively evaluates every alternative and then chooses the best one.

  1. Find largest divisible subset in array

  2. The Knight's tour problem

  3. Permutations of a given string

  4. Rat in a maze

Sort

Sorting algorithms move elements in a list into a specific order. They work by comparing elements to determine their order, and then moving them into a new order.

  1. Bubble Sort

  2. Merge Sort

  3. Quick Sort

Search

Search algorithms work by analyzing a user's query and finding the most relevant results.

  1. Array Subset

  2. Common in 3 Sorted Arrays

  3. Search missing element from array

  4. Find second largest in an array of positive integers

  5. Search subarray whose sum equals a target value

Hash
  1. Array Subset

Array

An array algorithm works by utilizing the structure of an array to efficiently access and manipulate data using indices.

  1. Count occurrences

  2. Find duplicate

  3. Find the majority element in the array

  4. Find minimum and maximum of an array using minimum number of comparisons

  5. Move negative to the beginning

  6. Find peak element in array

  7. Reverse an array

  8. Cyclically rotate

  9. Sort an array of 0s, 1s and 2s

  10. Sort array

Linked list
  1. Check if a linked list is circular

Queue
    Stack
    1. The celebrity

    Matrix

    Most matrix algorithms use nested loops to iterate through the rows and columns of the matrices, performing the necessary calculations for each element of the resulting matrix

    1. Boolean matrix

    2. Print boundary elements of a matrix

    3. Find common elements in all rows in one iteration

    4. Find number of islands inside a matrix.

    5. Find max number in each row of a matrix

    6. Multiplay two matrices

    7. Find peaks inside matrix

    8. Rotate matrix clockwise by 1

    9. Rotate matrix 180 degree

    10. Rotate matrix 270 degree

    11. Rotate matrix 90 degree

    12. Sort matrix in a strict order

    13. Find max sub rectangle

    14. Transpose of Matrix

    15. Travesal matrix in a spiral form

    Tree
      Heap
        Graph

        A graph algorithm works by traversing the nodes and edges of a graph, following the connections between them to solve a specific problem, like finding the shortest path between two nodes, identifying connected components, or detecting cycles, by exploring the graph step-by-step based on a set of rules, often using techniques like Depth-First Search (DFS) or Breadth-First Search (BFS) to visit each node in a structured order.

        1. Bellman–Ford algorithm

        2. Dijkstra's algorithm

        3. Floyd Warshall algorithm

        4. Find shortest path in an unweighted graph

        Number

        A "number algorithm" generally performs mathematical operations on numbers. The core of a number algorithm involves basic mathematical operations like addition, subtraction, multiplication, and division, often combined in complex ways depending on the problem.

        1. Find the factorial of a large number

        String

        A string algorithm, also called a string matching algorithm, generally searching for occurrences of a "pattern" within a "text" by comparing characters at each position and shifting the pattern along the text until a match is found.

        1. Convert Decimal number between 1 to 3999 to Roman numbers

        2. Number of Distinct Subsequences

        3. Given a number N, check if it is divisible by 7 or not.

        4. Encrypt string

        5. Find equal point of brackets in a string

        6. Isomorphic strings

        7. Check if two strings are k-anagrams or not

        8. Find longest common prefix in list of strings

        9. Find minimum distance between the given two words

        10. Find minimum number of deletions to make a string palindrome

        11. Panagram checking

        12. Reverse words

        13. Convert Roman number to integer

        14. Check if string is rotated by two places

        Dynamic Programming

        Recursive algorithms, while conceptually elegant, can be computationally expensive due to overlapping subproblems. Dynamic Programming techniques, encompassing memoization and tabulation, mitigate this inefficiency by storing the solutions to these subproblems. This allows for efficient retrieval and reuse of previously computed results, leading to a substantial improvement in the algorithm's overall time complexity.

        1. Arrange balls
          [Memoization] [Tabulation]

        2. Find Binomial coefficient
          [Memoization] [Tabulation]

        3. Find Nth Catalan Number
          [Memoization] [Tabulation]

        4. Climbing stairs with 3 moves
          [Memoization] [Tabulation]

        5. Climbing stairs
          [Memoization] [Tabulation]

        6. Find minimum coins to make change
          [Memoization] [Tabulation]

        7. Find number of way to make coin change
          [Memoization] [Tabulation]

        8. Find all subsequence combinations of a string
          [Memoization] [Tabulation]

        9. Count number of derangements
          [Memoization] [Tabulation]

        10. Find all distinct subset sums of an array
          [Memoization] [Tabulation]

        11. Find Nth Fibonacci number
          [Memoization] [Tabulation]

        12. House robber
          [Memoization] [Tabulation]

        13. Find minimum of jumps to reach end
          [Memoization] [Tabulation]

        14. 0/1 Knapsack problem
          [Memoization] [Tabulation]

        15. Unbounded knapsack
          [Memoization] [Tabulation]

        16. Longest common increasing subsequence (LCS + LIS)
          [Memoization] [Tabulation]

        17. Find longest common subsequence (LCS)
          [Memoization] [Tabulation]

        18. Find longest common substring
          [Memoization] [Tabulation]

        19. Find longest increasing subsequence (LIS)
          [Memoization] [Tabulation]

        20. Longest palindromic subsequence (LPS)
          [Memoization] [Tabulation]

        21. Maximum size of square sub-matrix with all 1s
          [Memoization] [Tabulation]

        22. Min cost path
          [Memoization] [Tabulation]

        23. Minimum insertions to form a palindrome
          [Memoization] [Tabulation]

        24. Find the minimum number of edits
          [Memoization] [Tabulation]

        25. Number of unique BST with N keys
          [Memoization] [Tabulation]

        26. Maximize number segments of cutted in length x, y and z
          [Memoization] [Tabulation]

        27. Find number of ways paint a fence with n posts and k colors
          [Memoization] [Tabulation]

        28. Partition a set into two subsets of equal sum
          [Memoization] [Tabulation]

        29. Pascal's Triangle
          [Memoization] [Tabulation]

        30. Regular expression wildcard pattern matching
          [Memoization] [Tabulation]

        31. Find number of permutation with K inversions
          [Memoization] [Tabulation]

        32. Print maximum number of A’s using given four keys
          [Memoization] [Tabulation]

        33. Stacking box
          [Memoization] [Tabulation]

        34. Subsequence with difference of 1
          [Memoization] [Tabulation]

        35. Subset sum
          [Memoization] [Tabulation]

        36. Maximize total tips
          [Memoization] [Tabulation]

        37. Find Nth Tribonacci number
          [Memoization] [Tabulation]

        38. Count unique paths in matrix from top left to bottom right
          [Memoization] [Tabulation]

        39. Weighted interval job scheduling
          [Memoization] [Tabulation]

        40. Word Break
          [Memoization] [Tabulation]

        Branch and bound
          Greedy

          A greedy algorithm is a problem-solving technique that chooses the best option at each step, with the goal of finding a globally optimal solution. Greedy algorithms are simple and easy to implement, but they don't always produce the best solution.

          1. Fractional Knapsack