Skip to content

papilo-cloud/leetcode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Leetcode Coding Patterns

  1. Two Pointers

    • The Two Pointers pattern involves using two pointers to iterate through an array or list, often used to find pairs or elements that meet specific criteria.
  2. Prefix Sum

    • Prefix Sum involves preprocessing an array to create a new array where each element at index i represents the sum of the array from the start up to i. This allows for efficient sum queries on subarrays.
  3. Sliding Window

    • The Sliding Window pattern is used to find a subarray or substring that satisfies a specific condition, optimizing the time complexity by maintaining a window of elements.
  4. Slow Fast Pointers

    • The Fast & Slow Pointers (Tortoise and Hare) pattern is used to detect cycles in linked lists and other similar structures.
  5. Top K Element

    • The Top 'K' Elements pattern finds the top k largest or smallest elements in an array or stream of data using heaps or sorting.
  6. Overlapping Intervals

    • The Overlapping Intervals pattern is used to merge or handle overlapping intervals in an array.
  7. Bit Manipulation

  8. Modified Binary Search

    • The Modified Binary Search pattern adapts binary search to solve a wider range of problems, such as finding elements in rotated sorted arrays.
    • Use this pattern for problems involving sorted or rotated arrays where you need to find a specific element.
  9. Monotonic Stack

    • The Monotonic Stack pattern uses a stack to maintain a sequence of elements in a specific order (increasing or decreasing).
    • Use this pattern for problems that require finding the next greater or smaller element.
  10. Monotonic Queue

    • The Monotonic Queue pattern uses a queue to maintain a sequence of elements in a specific order (increasing or decreasing).
  11. LinkedList In-place Reversal

    • The In-place Reversal of a LinkedList pattern reverses parts of a linked list without using extra space.
  12. Two Heaps

    • This approach is quite useful when dealing with the problems where we are given a set of elements such that we can divide them into two parts.
  13. Dynamic Programming

    • Dynamic Programming (DP) involves breaking down problems into smaller subproblems and solving them using a bottom-up or top-down approach.

    • Use this pattern for problems with overlapping subproblems and optimal substructure.