0% found this document useful (0 votes)
8 views7 pages

Array Operations and Algorithms Guide

Good
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views7 pages

Array Operations and Algorithms Guide

Good
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

1.

**Find the Maximum Element in an Array**


- Input: Array of integers
- Output: Maximum element

2. **Find the Minimum Element in an Array**


- Input: Array of integers
- Output: Minimum element

3. **Sum of Elements in an Array**


- Input: Array of integers
- Output: Sum of all elements

4. **Average of Elements in an Array**


- Input: Array of integers
- Output: Average

5. **Reverse an Array**
- Input: Array of integers
- Output: Reversed array

6. **Count Occurrences of an Element**


- Input: Array of integers, Element to count
- Output: Occurrences of the element in the array

7. **Check if an Array is Sorted**


- Input: Array of integers
- Output: True if sorted, False otherwise

8. **Merge Two Arrays**


- Input: Two arrays
- Output: A new merged array

9. **Find Duplicate Elements in an Array**


- Input: Array of integers
- Output: List of duplicate elements
10. **Find Unique Elements in an Array**
- Input: Array of integers
- Output: List of unique elements
11. **Rotate an Array by n Positions**
- Input: Array of integers, Number n
- Output: Rotated array

12. **Left Rotate an Array**


- Input: Array of integers
- Output: Left rotated array by one position

13. **Right Rotate an Array**


- Input: Array of integers
- Output: Right rotated array by one position

14. **Remove Duplicate Elements from an Array**


- Input: Array of integers
- Output: Array with duplicates removed

15. **Find the Second Largest Element in an Array**


- Input: Array of integers
- Output: Second largest element

16. **Find the Second Smallest Element in an Array**


- Input: Array of integers
- Output: Second smallest element

17. **Check if an Array is a Palindrome**


- Input: Array of integers
- Output: True if palindrome, False otherwise

18. **Bubble Sort**


- Input: Array of integers
- Output: Sorted array

19. **Selection Sort**


- Input: Array of integers
- Output: Sorted array

20. **Insertion Sort**


- Input: Array of integers
- Output: Sorted array

21. **Find the Largest Sum Contiguous Subarray (Kadane’s Algorithm)**


- Input: Array of integers
- Output: Largest sum subarray

22. **Check if Two Arrays are Equal**


- Input: Two arrays of integers
- Output: True if equal, False otherwise

23. **Find the Intersection of Two Arrays**


- Input: Two arrays of integers
- Output: Array of common elements

24. **Find the Union of Two Arrays**


- Input: Two arrays of integers
- Output: Array with unique elements from both arrays

25. **Find Missing Number in Array**


- Input: Array of integers (1 to n-1)
- Output: Missing number

26. **Count the Number of Even Numbers in an Array**


- Input: Array of integers
- Output: Count of even numbers

27. **Count the Number of Odd Numbers in an Array**


- Input: Array of integers
- Output: Count of odd numbers

28. **Find the First Non-Repeating Element in an Array**


- Input: Array of integers
- Output: First non-repeating element

29. **Find Common Elements in Three Sorted Arrays**


- Input: Three sorted arrays
- Output: Array of common elements

30. **Find the Product of All Elements Except Self**


- Input: Array of integers
- Output: Array where each element is the product of all elements except itself
31. **Find the Missing Element in a Sequence**
- Input: Array with numbers from 1 to n, but one number is missing
- Output: Missing number

32. **Sort Array in Descending Order**


- Input: Array of integers
- Output: Array sorted in descending order

33. **Sort Array in Ascending Order**


- Input: Array of integers
- Output: Array sorted in ascending order

34. **Find the Frequency of Elements in an Array**


- Input: Array of integers
- Output: Frequency of each element

35. **Find Pair with Given Sum**


- Input: Array of integers, Target sum
- Output: Pair of elements that sum up to the target

36. **Find All Pairs with Given Sum**


- Input: Array of integers, Target sum
- Output: All pairs of elements that sum up to the target

37. **Find the Element with the Maximum Frequency**


- Input: Array of integers
- Output: Element with the highest frequency

38. **Find the Element with the Minimum Frequency**


- Input: Array of integers
- Output: Element with the lowest frequency

39. **Print Array in Reverse Order**


- Input: Array of integers
- Output: Array printed in reverse order

40. **Count the Total Number of Elements Greater Than a Specific Value**
- Input: Array of integers, Specific value
- Output: Count of elements greater than the value

41. **Find the Largest Element Smaller Than a Given Value**


- Input: Array of integers, Value
- Output: Largest element smaller than the value

42. **Count the Number of Negative Numbers in an Array**


- Input: Array of integers
- Output: Count of negative numbers

43. **Count the Number of Positive Numbers in an Array**


- Input: Array of integers
- Output: Count of positive numbers

44. **Find the Largest Prime Number in an Array**


- Input: Array of integers
- Output: Largest prime number

45. **Find the Smallest Prime Number in an Array**


- Input: Array of integers
- Output: Smallest prime number
46. **Find the Product of Array Elements**
- Input: Array of integers
- Output: Product of all elements

47. **Find All Odd Numbers in an Array**


- Input: Array of integers
- Output: Array of odd numbers

48. **Find All Even Numbers in an Array**


- Input: Array of integers
- Output: Array of even numbers

49. **Check if an Array Contains a Specific Element**


- Input: Array of integers, Element to check
- Output: True if element exists, False otherwise
50. **Sum of Array After Removing Specific Element**
- Input: Array of integers, Element to remove
- Output: Sum of elements after removal

51. **Remove Even Numbers from Array**


- Input: Array of integers
- Output: Array without even numbers

52. **Remove Odd Numbers from Array**


- Input: Array of integers
- Output: Array without odd numbers

53. **Find Maximum Subarray Sum (Kadane's Algorithm)**


- Input: Array of integers
- Output: Maximum sum of a subarray

54. **Find the Count of Positive and Negative Numbers in an Array**


- Input: Array of integers
- Output: Count of positive and negative numbers

55. **Find the Count of Zero Elements in an Array**


- Input: Array of integers
- Output: Count of zero elements
56. **Sort an Array of Strings by Length**
- Input: Array of strings
- Output: Array sorted by string length

57. **Find the Missing Number in a Sorted Array**


- Input: Sorted array of integers from 1 to n
- Output: Missing number

58. **Find the Majority Element (if exists)**


- Input: Array of integers
- Output: Majority element or "No Majority"

59. **Find the Largest Contiguous Subarray with Sum Equal to Zero**
- Input: Array of integers
- Output: Largest subarray with sum zero

60. **Find the First Repeated Element**


- Input: Array of integers
- Output: First repeated element
61. **Find the Last Repeated Element**
- Input: Array of integers
- Output: Last repeated element

62. **Split an Array into Two Equal Parts**


- Input: Array of integers
- Output: Two sub-arrays

63. **Count the Number of Elements Greater Than the Average**


- Input: Array of integers
- Output: Count of elements greater than the average

64. **Find the Kth Largest Element in an Array**


- Input: Array of integers, K
- Output: Kth largest

element in the array

### 65. **Find the Kth Smallest Element in an Array**


- Input: Array of integers, K
- Output: Kth smallest element in the array

### 66. **Find the Longest Consecutive Subarray**


- Input: Array of integers
- Output: Longest consecutive subarray

### 67. **Find All Subarrays of an Array**


- Input: Array of integers
- Output: List of all subarrays

### 68. **Find the Sum of Diagonal Elements in a 2D Array**


- Input: 2D array (matrix)
- Output: Sum of diagonal elements

### 69. **Transpose a Matrix**


- Input: 2D array (matrix)
- Output: Transposed matrix

### 70. **Find the Row with Maximum Sum in a 2D Array**


- Input: 2D array (matrix)
- Output: Row with the maximum sum

### 71. **Check if a Matrix is Symmetric**


- Input: 2D array (matrix)
- Output: True if matrix is symmetric, False otherwise

### 72. **Spiral Traversal of a Matrix**


- Input: 2D array (matrix)
- Output: Array of elements in spiral order

### 73. **Print Matrix Diagonals**


- Input: 2D array (matrix)
- Output: Two arrays representing primary and secondary diagonals

### 74. **Find the Longest Increasing Subsequence (LIS)**


- Input: Array of integers
- Output: Longest increasing subsequence

### 75. **Find All Pairs in an Array Whose Sum Equals Zero**
- Input: Array of integers
- Output: All pairs whose sum equals zero

### 76. **Find the Common Prefix in an Array of Strings**


- Input: Array of strings
- Output: Common prefix among the strings

### 77. **Find the Minimum Subarray of Size K**


- Input: Array of integers, Size K
- Output: Subarray of size K with the minimum sum

### 78. **Find the Maximum Subarray of Size K**


- Input: Array of integers, Size K
- Output: Subarray of size K with the maximum sum

### 79. **Check if Array Contains Duplicate Within K Distance**


- Input: Array of integers, K (distance)
- Output: True if duplicate exists within K distance, False otherwise

### 80. **Rearrange Positive and Negative Numbers in an Array**


- Input: Array of integers
- Output: Array with positive and negative numbers arranged

### 81. **Find the Majority Element (More than N/2 Occurrences)**
- Input: Array of integers
- Output: Majority element or "No Majority"

### 82. **Find the Longest Substring Without Repeating Characters**


- Input: String
- Output: Longest substring without repeating characters

### 83. **Count the Number of Subarrays with a Given Sum**


- Input: Array of integers, Target sum
- Output: Count of subarrays with the given sum

### 84. **Check if Array is a Subarray of Another Array**


- Input: Two arrays
- Output: True if the second array is a subarray of the first, False otherwise

### 85. **Find the Median of Two Sorted Arrays**


- Input: Two sorted arrays
- Output: Median of the two arrays

### 86. **Find the Maximum Difference Between Two Elements in an Array**
- Input: Array of integers
- Output: Maximum difference between two elements

### 87. **Find All Permutations of an Array**


- Input: Array of integers
- Output: List of all permutations of the array

### 88. **Find All Combinations of a Given Sum**


- Input: Array of integers, Target sum
- Output: List of combinations that sum to the target

### 89. **Find the Peak Element in an Array**


- Input: Array of integers
- Output: Peak element (element greater than or equal to its neighbors)
### 90. **Find the Length of Longest Consecutive Sequence**
- Input: Array of integers
- Output: Length of the longest consecutive subsequence

### 91. **Find the Missing Number in a Range**


- Input: Array of integers from 1 to n with one number missing
- Output: Missing number

### 92. **Find the Count of Subarrays with Even Sum**


- Input: Array of integers
- Output: Count of subarrays with even sum

### 93. **Find the Count of Subarrays with Odd Sum**


- Input: Array of integers
- Output: Count of subarrays with odd sum

### 94. **Check if Two Arrays are Rotations of Each Other**


- Input: Two arrays
- Output: True if one array is a rotation of the other, False otherwise

### 95. **Sort an Array of 0s, 1s, and 2s**


- Input: Array of integers (only 0s, 1s, and 2s)
- Output: Array sorted in ascending order

### 96. **Find the Largest Rectangle in Histogram**


- Input: Array of heights representing a histogram
- Output: Area of the largest rectangle that can be formed

### 97. **Check if an Array is an Arithmetic Progression**


- Input: Array of integers
- Output: True if the array forms an arithmetic progression, False otherwise

### 98. **Find the Longest Increasing Subsequence (Binary Search Optimization)**
- Input: Array of integers
- Output: Longest increasing subsequence (optimized version using binary search)

### 99. **Find the Maximum Product Subarray**


- Input: Array of integers
- Output: Maximum product of a contiguous subarray

### 100. **Find the Smallest Subarray with Sum Greater than a Given Value**
- Input: Array of integers, Target sum
- Output: Smallest subarray whose sum is greater than the target

You might also like