72Laboratories

πŸ“š 30 Repeated Coding Problems on Arrays


πŸ” Searching & Sorting

  1. Search an element in an array
    • Linear Search
    • Binary Search (on sorted array)
  2. Sort elements in an array
    • Bubble Sort
  3. Merge two sorted arrays

  4. Sort an array according to the order defined by another array

  5. Sort elements of an array by frequency

πŸ”’ Finding Elements

  1. Find the majority element in an array
    (element that appears more than ⌊n/2βŒ‹ times)

  2. Find the smallest number in an array

  3. Find the largest number in an array

  4. Find the second smallest and second largest element

  5. Find the missing number in a sequence array

  6. Find all repeating elements in an array

  7. Find all non-repeating elements in an array

  8. Find all symmetric pairs in an array

  9. Find the maximum product subarray

  10. Find the equilibrium index of an array
    (index where sum of elements on the left is equal to the sum on the right)


πŸ”„ Rearranging & Rotating

  1. Reverse a given array

  2. Rotate an array by K elements
    • Using Block Swap Algorithm
    • Left/Right rotation
  3. Find the circular rotation of an array by K positions

  4. Rearrange the array in increasing-decreasing order

πŸ“Š Frequency & Count

  1. Count the frequency of each element

  2. Remove duplicates from a sorted array

  3. Remove duplicates from an unsorted array

  4. Replace each element by its rank in the array


βž• Additional Operations

  1. Add an element in an array

  2. Calculate the sum of elements

  3. Find the average of elements

  4. Find the median of the array

  5. Check if an array is a subset of another array

  6. Search for an element in an array
    (generic placeholder for customized search techniques)


πŸ“ Bonus Problem

  1. Sort an array according to the frequency of elements

πŸ“Œ Pro Tip

βœ… Practice these problems both iteratively and recursively (where applicable).
βœ… Attempt them using different data structures: Arrays, ArrayLists, HashMaps, and Sets.