Arrays

Master array manipulation with fundamental problems covering searching, sorting, and advanced algorithms.

Showing 21 of 21 questions
Easy: 0 Medium: 0 Hard: 0
QUESTIONDIFFICULTY
Buy and Sell Stock (Maximum Profit)
Find the maximum profit from buying and selling stock with at most one transaction
Easy
Check if Array is Sorted
Determine if an array is sorted in ascending, descending, or not sorted at all
Easy
Find the Maximum Element in an Array
Find and return the largest element in an array of integers
Easy
Find Missing Number (1 to n)
Find the missing number in an array containing n distinct numbers taken from 1, 2, 3, ..., n+1
Easy
Intersection of Two Arrays
Find the intersection of two arrays and return the result as an array
Easy
Find Majority Element (Boyer-Moore Algorithm)
Find the majority element that appears more than n/2 times using Boyer-Moore majority vote algorithm
Easy
Merge Two Sorted Arrays
Merge two sorted arrays into a single sorted array in-place
Easy
Move All Zeros to the End
Move all zeros in an array to the end while maintaining the relative order of non-zero elements
Easy
Reverse an Array
Reverse the order of elements in an array in-place and return the modified array
Easy
Find the Second Largest Element in an Array
Find and return the second largest element in an array of integers
Easy
Two Sum
Find two numbers in an array that add up to a target value
Easy
Find Duplicate Number
Find the duplicate number in an array containing n+1 integers where each integer is between 1 and n (inclusive)
Medium
Longest Consecutive Sequence
Find the length of the longest consecutive elements sequence
Medium
Maximum Subarray Sum (Kadane's Algorithm)
Find the contiguous subarray with maximum sum using Kadane's algorithm
Medium
Minimum Swaps to Sort Array
Find the minimum number of swaps required to sort an array
Medium
Product of Array Except Self
Return an array where each element is the product of all elements except itself
Medium
Rotate Array
Rotate an array to the right by k steps
Medium
Sliding Window Maximum
Find the maximum element in each sliding window of size k
Medium
Subarray with Given Sum
Find a continuous subarray which adds to a given number
Medium
Three Sum (Triplets that Sum to Zero)
Find all unique triplets in the array which gives the sum of zero
Medium
Trapping Rain Water
Calculate how much rainwater can be trapped between bars of different heights
Hard

Overview

Arrays are one of the most fundamental data structures in computer science. This section covers essential array manipulation techniques, from basic operations to advanced algorithms.

Key Concepts

  • Array traversal and iteration
  • Two-pointer technique
  • Sliding window
  • Prefix sums
  • Sorting and searching
  • In-place modifications

Common Problems

Easy

  • Two Sum
  • Remove Duplicates from Sorted Array
  • Best Time to Buy and Sell Stock
  • Merge Sorted Array

Medium

  • 3Sum
  • Container With Most Water
  • Product of Array Except Self
  • Rotate Array

Hard

  • Trapping Rain Water
  • Median of Two Sorted Arrays
  • First Missing Positive

Practice Tips

  1. Start with brute force: Always think through the naive solution first
  2. Optimize space: Many array problems can be solved in-place
  3. Consider edge cases: Empty arrays, single elements, duplicates
  4. Time complexity: Aim for O(n) or O(n log n) solutions

Resources