Geeksforgeeks Org Array Subarray Subsequence and Subset Ref LBP
Geeksforgeeks Org Array Subarray Subsequence and Subset Ref LBP
DSA Data Structures Algorithms Interview Preparation Data Science Topic-wise Practice C C++ Java Python Latest Blogs Competitive Programming JavaScript Machine Learning Write & Earn Web Development Puzzles Projects
Write an Article
Courses
Write an Interview Experience
Subarrays, Subsequences, and Subsets in Array
Last Updated : 15 Sep, 2022
Array Data Structure
What is a Subsequence?
A subsequence is a sequence that can be derived from another sequence by removing zero or more elements, without changing
n
More generally, we can say that for a sequence of size n, we can have (2 – 1) non-empty sub-sequences in total.
For the same above example, there are 15 sub-sequences. They are:
What is a Subset?
If a Set has all its elements belonging to other sets, this set will be known as a subset of the other set.
Then, A ⊆ B.
Topic s :
What is Subarray What is Subsequence What is Subset
Problems on Subarray:
6. Maximum length of the sub-array whose first and last element s are same
9. Maximum subsequence sum such that all element s are K distance apar t
12. Length of Smallest subarray in range 1 to N with sum greater than a given value
14. Split array into K disjoint subarrays such that sum of each subarray is odd.
18. Count of subarrays which star t and end with the same element
20. Split array into two subarrays such that dif ference of their maximum is minimum
3. Min dif ference between maximum and minimum element in all Y size subarrays
4. Longest subarray of non-empty cells af ter removal of at most a single empty cell
8. Count subarrays having sum of element s at even and odd positions equal
10. Minimum Decrement s on Subarrays required to reduce all Array element s to zero
11. Split array into two subarrays such that dif ference of their sum is minimum
13. Smallest subarray which upon repetition gives the original array
14. Split array into maximum subarrays such that ever y distinct element lies in a single subarray
18. Length of smallest subarray to be removed such that the remaining array is sor ted
20. Length of the longest increasing subsequence which does not contain a given sequence as Subarray
2. Maximum length of same indexed subarrays from two given arrays satisf ying the given condition
3. Count ways to split array into two equal sum subarrays by changing sign of any one array element
9. Minimize dif ference between maximum and minimum array element s by removing a K-length subarray
11. Minimum removal of element s from end of an array required to obtain sum K
12. Check if any subarray of length M repeat s at least K times consecutively or not
13. Minimize flips on K-length subarrays required to make all array element s equal to 1
14. Split array into K subarrays such that sum of maximum of all subarrays is maximized
15. Find minimum subarray sum for each index i in subarray [i, N-1]
19. Find a subsequence which upon reversing gives the maximum sum subarray
20. Minimize steps to make Array element s 0 by reducing same A[i] – X from Subarray
Problems on Subsequence:
7. Length of the longest subsequence such that xor of adjacent element s is non-decreasing
9. Length of Smallest Subsequence such that sum of element s is greater than equal to K
11. Maximum length Subsequence with alternating sign and maximum Sum
12. Count of possible subarrays and subsequences using given length of Array
17. Minimize element s to be added to a given array such that it contains another given array as it s subsequence
18. Maximize subsequences having array element s not exceeding length of the subsequence
5. Minimum number of inser tions required such that first K natural numbers can be obtained as sum of a subsequence of the
array
6. Length of longest subsequence such that prefix sum at ever y element remains greater than zero
7. Check if given Array can be divided into subsequences of K increasing consecutive integers
8. Longest Subsequence such that dif ference between adjacent element s is either A or B
12. Sor ted subsequence of size 3 in linear time using constant space
14. Construct array having X subsequences with maximum dif ference smaller than d
16. Longest Subsequence with at least one common digit in ever y element
9. Smallest subsequence with sum of absolute dif ference of consecutive element s maximized
12. Longest subsequence of a number having same lef t and right rotation
17. Print all possible K-length subsequences of first N natural numbers with sum N
18. Longest subsequence having dif ference between the maximum and minimum element equal to K
19. Maximize dif ference between sum of even and odd-indexed element s of a subsequence
20. Conver t an array into another by repeatedly removing the last element and placing it at any arbitrar y index
Problems on Subset:
8. Par tition a set into two subset s such that dif ference between max of one and min of other is minimized
9. Sum of all possible expressions of a numeric string possible by inser ting addition operators
10. Check if it ’s possible to split the Array into strictly increasing subset s of size at least K
8. Sum of (maximum element – minimum element) for all the subset s of an array
12. Count of subset s having sum of min and max element less than K
13. Split array into two equal length subset s such that all repetitions of a number lies in a single subset
14. Nth Subset of the Sequence consisting of powers of K in increasing order of their Sum
15. L argest possible Subset from an Array such that no element is K times any other element in the Subset
2. Split array into K-length subset s to minimize sum of second smallest element of each subset
5. Sum of length of two smallest subset s possible from a given array with sum at least K
6. Reduce sum of any subset of an array to 1 by multiplying all it s element s by any value
7. Sum of all subset s whose sum is a Per fect Number from a given array
11. Count ways to place ‘+’ and ‘-‘ in front of array element s to obtain sum K
12. Count ways to split array into two subset s having dif ference between their sum equal to K
15. Minimum count of element s to be inser ted in Array to form all values in [1, K] using subset sum
16. Maximum subset sum having dif ference between it s maximum and minimum in range [L, R]
17. Find all unique subset s of a given set using C++ STL
Please write comments if you find anything incorrect, or if you want to share more information about the topic discussed above
Related Articles
1. Print BST from array of strings where every string contains leaf nodes removed in iteration
3. Array | Searching
4. Array | Sorting
5. Array Rearrangement