avatar_url

Sandesh Rana | Python

I'm a developer from Himalayas, with a passion for crafting efficient and elegant code, with creativity and precision.

Searching and sorting

21 Aug 2024 » programming, algorithm

Sorting and Searching: Easy to Hard Problems

Easy

  1. Binary Search (Basic binary search in a sorted array)
  2. Search Insert Position (Finds the position to insert an element in a sorted array)
  3. Merge Sorted Array (Merges two sorted arrays)
  4. First Bad Version (Finds the first bad version in a range using binary search)
  5. Find Peak Element (Finds a peak element in an array using binary search)

Medium

  1. Kth Largest Element in an Array (Finds the Kth largest element using sorting or heap)
  2. Find Minimum in Rotated Sorted Array (Finds the minimum element in a rotated sorted array)
  3. Search in Rotated Sorted Array (Searches for an element in a rotated sorted array)
  4. Top K Frequent Elements (Finds the K most frequent elements using sorting and heap)
  5. Median of Two Sorted Arrays (Finds the median of two sorted arrays)

Hard

  1. Largest Rectangle in Histogram (Finds the largest rectangle in a histogram using stack-based approach)
  2. Trapping Rain Water (Calculates trapped water in an elevation map using two-pointer technique)
  3. Find K Pairs with Smallest Sums (Finds K pairs with the smallest sums from two sorted arrays using heap)
  4. Median of Two Sorted Arrays (Finds the median of two sorted arrays efficiently)
  5. Kth Largest Element in a Stream (Keeps track of the Kth largest element in a stream of numbers)