Array Data Structure

‘Recent Articles’ on Arrays

Topic :

Array Introduction :

Array Rotations :

More >>

Arrangement Rearrangement :

  1. Rearrange positive and negative numbers in O(n) time and O(1) extra space
  2. Write a program to reverse an array or string
  3. Sort an array in wave form
  4. Rearrange positive and negative numbers with constant extra space
  5. Sort an array according to absolute difference with given value
  6. Move all negative elements to end in order with extra space allowed
  7. Three way partitioning of an array around a given range
  8. Rearrange an array in maximum minimum form | Set 1
  9. Rearrange an array in maximum minimum form | Set 2 (O(1) extra space)
  10. Maximum Length Bitonic Subarray
  11. Maximize sum of consecutive differences in a circular array
  12. Alternative Sorting
  13. Segregate 0s and 1s in an array
  14. Segregate Even and Odd numbers
  15. Longest Bitonic Subsequence
  16. Find a sorted subsequence of size 3 in linear time
  17. Largest subarray with equal number of 0s and 1s
  18. Dynamic Programming | Set 18 (Partition problem)
  19. Maximum Product Sub-array
  20. Replace every element with the greatest element on right side
  21. Sort a nearly sorted (or K sorted) array
  22. Maximum circular subarray sum
  23. Shuffle a given array
  24. Construction of Longest Increasing Subsequence (N log N)
  25. Arrange given numbers to form the biggest number
  26. Divide and Conquer | Set 3 (Maximum Subarray Sum)
  27. Sort elements by frequency | Set 2
  28. Merge k sorted arrays
  29. Sort an array according to the order defined by another array
  30. Find Index of 0 to be replaced with 1 to get longest continuous sequence of 1s in a binary array
  31. Rearrange an array such that ‘arr[j]’ becomes ‘i’ if ‘arr[i]’ is ‘j’
  32. Replace every array element by multiplication of previous and next
  33. Generate all possible sorted arrays from alternate elements of two given sorted arrays
  34. Minimum number of swaps required for arranging pairs adjacent to each other
  35. Convert array into Zig-Zag fashion
  36. Reorder an array according to given indexes
  37. Form minimum number from given sequence

More >>

Order Statistics :

  1. k largest(or smallest) elements in an array | added Min Heap method
  2. Kth smallest element in a row-wise and column-wise sorted 2D array | Set 1
  3. Program to find largest element in an array
  4. K’th Smallest/Largest Element in Unsorted Array | Set 1
  5. K’th Smallest/Largest Element in Unsorted Array | Set 2 (Expected Linear Time)
  6. K’th Smallest/Largest Element in Unsorted Array | Set 3 (Worst Case Linear Time)
  7. Find the largest three elements in an array
  8. Find all elements in array which have at-least two greater elements
  9. Find k pairs with smallest sums in two arrays
  10. k-th smallest absolute difference of two elements in an array
  11. Find Second largest element in an array
  12. Find k numbers with most occurrences in the given array
  13. Find the smallest and second smallest elements in an array
  14. Next Greater Element
  15. Find the smallest missing number
  16. Maximum sum such that no two elements are adjacent
  17. Maximum and minimum of an array using minimum number of comparisons
  18. Maximum difference between two elements such that larger element appears after the smaller number
  19. Given an array arr[], find the maximum j – i such that arr[j] > arr[i]
  20. Maximum of all subarrays of size k
  21. Find the minimum distance between two numbers
  22. Find the maximum element in an array which is first increasing and then decreasing
  23. Count smaller elements on right side
  24. Longest Monotonically Increasing Subsequence Size (N log N)
  25. Find the smallest positive number missing from an unsorted array | Set 1
  26. Find the maximum repeating number in O(n) time and O(1) extra space
  27. Given an array of of size n and a number k, find all elements that appear more than n/k times
  28. Find the Increasing subsequence of length three with maximum product
  29. Maximum Sum Path in Two Arrays
  30. Find the closest pair from two sorted arrays
  31. Find the largest pair sum in an unsorted array
  32. Online algorithm for checking palindrome in a stream
  33. Find zeroes to be flipped so that number of consecutive 1’s is maximized
  34. Count Strictly Increasing Subarrays

More >>

Range Queries :

More >>

Optimization Problems :

Searching and Sorting :

  1. Search, insert and delete in an unsorted array
  2. Search, insert and delete in a sorted array
  3. Given an array A[] and a number x, check for pair in A[] with sum as x
  4. Majority Element
  5. Find the Number Occurring Odd Number of Times
  6. Find the Missing Number
  7. Merge an array of size n into another array of size m+n
  8. Leaders in an array
  9. Sort elements by frequency | Set 1
  10. Count Inversions in an array | Set 1 (Using Merge Sort)
  11. Two elements whose sum is closest to zero
  12. Check for Majority Element in a sorted array
  13. Union and Intersection of two sorted arrays
  14. Ceiling in a sorted array
  15. Find the two repeating elements in a given array
  16. Sort an array of 0s, 1s and 2s
  17. Find the Minimum length Unsorted Subarray, sorting which makes the complete array sorted
  18. Equilibrium index of an array
  19. Count number of occurrences (or frequency) in a sorted array
  20. Find the repeating and the missing | Added 3 new methods
  21. Median in a stream of integers (running integers)
  22. Find a Fixed Point in a given array
  23. Find sub-array with given sum
  24. Find a triplet that sum to a given value
  25. Find the two numbers with odd occurrences in an unsorted array
  26. Find a pair with the given difference
  27. Find four elements that sum to a given value | Set 1 (n^3 solution)
  28. Find four elements that sum to a given value | Set 2 ( O(n^2Logn) Solution)
  29. Median of two sorted arrays of different sizes
  30. Count the number of possible triangles
  31. Find a peak element
  32. Find number of pairs (x, y) in an array such that x^y > y^x
  33. Count all distinct pairs with difference equal to k
  34. Find if there is a sub-array with 0 sum
  35. Given a sorted array and a number x, find the pair in array whose sum is closest to x
  36. Count 1’s in a sorted binary array
  37. Print All Distinct Elements of a given integer array
  38. Construct an array from its pair-sum array
  39. Find common elements in three sorted arrays
  40. Find the first repeating element in an array of integers
  41. Find position of an element in a sorted array of infinite numbers
  42. Check if a given array contains duplicate elements within k distance from each other
  43. Find the element that appears once
  44. Find Union and Intersection of two unsorted arrays
  45. Delete an element from array (Using two traversals and one traversal)
  46. Count frequencies of all elements in array in O(1) extra space and O(n) time
  47. Trapping Rain Water
  48. Count triplets with sum smaller than a given value
  49. Count Inversions of size three in a given array
  50. Merge two sorted arrays with O(1) extra space
  51. Find lost element from a duplicated array
  52. Count pairs with given sum

More on Searching >>
More on Sorting >>

Matrix :

More >>

Misc :

Quick Links :

If you like GeeksforGeeks and would like to contribute, you can also write an article and mail your article to See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above

Company Wise Coding Practice    Topic Wise Coding Practice