Techniques

General Strategies

Patterns

  • Two Pointer
  • Sliding Window
  • Fast and Slow Pointer
  • Prefix Sum
Operation

Sort

Search

Tree Traversal

  • In Order
  • Pre Order
  • Post Order

Hash


Recursion / Dynamic Programming

Recursive paradigms enable the systematic decomposition of problems into isomorphic subsegments, providing robust intuition for algorithmic design. Nonetheless, naive recursion frequently incurs high computational overhead from overlapping evaluations. Dynamic programming mitigates this drawback via memoization and tabulation, storing intermediate states to optimize retrieval and fundamentally enhance overall computational efficiency.

  1. Find Nth Fibonacci number
    [Recursion] [Memoization] [Tabulation]

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

  3. Find Binomial coefficient
    [Recursion] [Memoization] [Tabulation]

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

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

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

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

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

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

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

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

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

  13. Climbing stairs
    [Recursion] [Memoization] [Tabulation]

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

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

  16. Arrange balls
    [Recursion] [Memoization] [Tabulation]

  17. Stacking box
    [Recursion] [Memoization] [Tabulation]

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

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

  20. Unbounded knapsack
    [Recursion] [Memoization] [Tabulation]

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

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

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

  24. Subset sum
    [Recursion] [Memoization] [Tabulation]

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

  26. Maximize total tips
    [Recursion] [Memoization] [Tabulation]

  27. House robber
    [Recursion] [Memoization] [Tabulation]

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

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

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

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

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

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

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

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

  36. Word break
    [Recursion] [Memoization] [Tabulation]

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

  38. Min cost path
    [Recursion] [Memoization] [Tabulation]

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

  40. Regular expression wildcard pattern matching
    [Recursion] [Memoization] [Tabulation]

Backtracking / Branch and bound

Backtracking builds solutions incrementally by exploring options recursively. For optimization problems, Branch and Bound enhances this approach by evaluating each path with a mathematical limit. If a branch cannot possibly outperform the current best solution, the algorithm instantly prunes it to save computational effort.

  1. Find largest divisible subset in array

  2. The Knight's tour problem

  3. Permutations of a given string

  4. Rat in a maze

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

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

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 array

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

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

      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

      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

      Heap