‘Recent Articles’ on Arrays

Topic :

Quick Links

Array Rotations :

  1. Program for array rotation
  2. Reversal algorithm for array rotation
  3. Block swap algorithm for array rotation
  4. Program to cyclically rotate an array by one
  5. Search an element in a sorted and rotated array
  6. Given a sorted and rotated array, find if there is a pair with a given sum
  7. Find maximum value of Sum( i*arr[i]) with only rotations on given array allowed
  8. Maximum sum of i*arr[i] among all rotations of a given array
  9. Find the Rotation Count in Rotated Sorted array
  10. Quickly find multiple left rotations of an array
  11. Find the minimum element in a sorted and rotated array
  12. 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
  38. 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
  35. More >>

Range Queries :

  1. MO’s Algorithm
  2. Range Minimum Query (Square Root Decomposition and Sparse Table)
  3. GCDs of given index ranges in an array
  4. Range LCM Queries
  5. Sqrt (or Square Root) Decomposition Technique | Set 1 (Introduction)
  6. Range Queries for Frequencies of array elements
  7. Constant time range add operation on an array
  8. Find whether a subarray is in form of a mountain or not
  9. Queries for GCD of all numbers of an array except elements in a given range
  10. Number of elements less than or equal to a given number in a given subarray
  11. Number of elements less than or equal to a given number in a given subarray | Set 2 (Including Updates)
  12. Check in binary array the number represented by a subarray is odd or even
  13. Queries for counts of array elements with values in given range
  14. Queries for decimal values of subarrays of a binary array
  15. Merge Overlapping Intervals
  16. Check if any two intervals overlap among a given set of intervals
  17. More >>

Optimization Problems :

  1. Largest Sum Contiguous Subarray
  2. Maximum profit by buying and selling a share at most twice
  3. Find the subarray with least average
  4. Find the minimum distance between two numbers
  5. Minimize the maximum difference between the heights
  6. Minimum number of jumps to reach end
  7. Dynamic Programming | Set 14 (Maximum Sum Increasing Subsequence)
  8. Smallest subarray with sum greater than a given value
  9. Find maximum average subarray of k length
  10. Count minimum steps to get the given desired array
  11. Find minimum number of merge operations to make an array palindrome
  12. Find the smallest positive integer value that cannot be represented as sum of any subset of a given array
  13. Find minimum difference between any two elements
  14. Longest Span with same Sum in two Binary arrays

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 :

  1. Turn an image by 90 degree
  2. Rotate Matrix Elements
  3. Inplace rotate square matrix by 90 degrees | Set 1
  4. Rotate a matrix by 90 degree without using any extra space | Set 2
  5. Rotate each ring of matrix anticlockwise by K elements
  6. Check if all rows of a matrix are circular rotations of each other
  7. Magic Square
  8. Find the row with maximum number of 1s
  9. Find the number of islands
  10. Magic Square | Even Order
  11. Find median in row wise sorted matrix
  12. Number of cells a queen can move with obstacles on the chessborad
  13. Matrix Multiplication | Recursive
  14. Program to print Lower triangular and Upper triangular matrix of an array
  15. Find distinct elements common to all rows of a matrix
  16. More >>

Misc :

  1. Subarray/Substring vs Subsequence and Programs to Generate them
  2. A Product Array Puzzle
  3. Linked List vs Array
  4. Check if array elements are consecutive | Added Method 3
  5. Find whether an array is subset of another array | Added Method 3
  6. Implement two stacks in an array

Quick Links :

If you like GeeksforGeeks and would like to contribute, you can also write an article and mail your article to contribute@geeksforgeeks.org. 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