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. Find Nth Fibonacci number

  2. Find Nth Tribonacci number

  3. Find Binomial coefficient

  4. Find Nth Catalan Number

  5. List permutations of a given string

  6. Find all subsequence combinations of a string

  7. Pascal's Triangle

  8. Find all distinct subset sums of an array

  9. Number of unique BST with N keys

  10. Count number of derangements

  11. Find number of permutation with K inversions

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

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

  14. Climbing stairs

  15. Climbing stairs with 3 moves

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

  17. Arrange balls

  18. Stacking box

  19. Find minimum of jumps to reach end

  20. Weighted interval job scheduling

  21. Unbounded knapsack

  22. 0/1 Knapsack problem

  23. Find number of way to make coin change

  24. Find minimum coins to make change

  25. Subset sum

  26. Partition a set into two subsets of equal sum

  27. Maximize total tips

  28. House robber

  29. Find longest increasing subsequence (LIS)

  30. Subsequence with difference of 1

  31. Longest palindromic subsequence (LPS)

  32. Minimum insertions to form a palindrome

  33. Find the minimum number of edits

  34. Find longest common substring

  35. Find longest common subsequence (LCS)

  36. Longest common increasing subsequence (LCS + LIS)

  37. Word break

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

  39. Min cost path

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

  41. Regular expression wildcard pattern matching

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

  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. Breadth-first search

        3. Depth-first search

        4. Dijkstra's algorithm

        5. Edmonds-Karp maximum flow

        6. Floyd Warshall algorithm

        7. Ford-Fulkerson maximum flow

        8. Kruskal's minimum spanning tree

        9. Prim's minimum spanning tree

        10. 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. Determine whether a given number is a prime number.

        2. 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. Find Nth Fibonacci number
          [Memoization] [Tabulation]

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

        3. Find Binomial coefficient
          [Memoization] [Tabulation]

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

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

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

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

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

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

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

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

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

        13. Climbing stairs
          [Memoization] [Tabulation]

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

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

        16. Arrange balls
          [Memoization] [Tabulation]

        17. Stacking box
          [Memoization] [Tabulation]

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

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

        20. Unbounded knapsack
          [Memoization] [Tabulation]

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

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

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

        24. Subset sum
          [Memoization] [Tabulation]

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

        26. Maximize total tips
          [Memoization] [Tabulation]

        27. House robber
          [Memoization] [Tabulation]

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

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

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

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

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

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

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

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

        36. Word break
          [Memoization] [Tabulation]

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

        38. Min cost path
          [Memoization] [Tabulation]

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

        40. Regular expression wildcard pattern matching
          [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