Horje
Subarrays, Subsequences, and Subsets in Array

What is a Subarray?

subarray is a contiguous part of array, i.e., Subarray is an array that is inside another array.

In general, for an array of size n, there are n*(n+1)/2 non-empty subarrays.

For example, Consider the array [1, 2, 3, 4], There are 10 non-empty sub-arrays. The subarrays are:

(1), (2), (3), (4), (1,2), (2,3), (3,4), (1,2,3), (2,3,4), and (1,2,3,4)

Subarray

What is a Subsequence?

subsequence is a sequence that can be derived from another sequence by removing zero or more elements, without changing the order of the remaining elements.

More generally, we can say that for a sequence of size n, we can have (2n – 1) non-empty sub-sequences in total.

For the same above example, there are 15 sub-sequences. They are:

(1), (2), (3), (4), (1,2), (1,3),(1,4), (2,3), (2,4), (3,4), (1,2,3), (1,2,4), (1,3,4), (2,3,4), (1,2,3,4).

Subsequences

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.

A Subset is denoted as ““. If set A is a subset of set B, it is represented as A ⊆ B.

For example, Let Set_A = {m, n, o, p, q}, Set_ B = {k, l, m, n, o, p, q, r}

Then, A ⊆ B.

Subset

Easy Problems on Subarray:

Medium Problems on Subarray:

Hard Problems on Subarray:

Easy Problems on Subsequence:

Medium Problems on Subsequence:

Hard Problems on Subsequence:

Easy Problems on Subset:

Medium Problems on Subset:

Hard Problems on Subset:

Related Articles:

Data Structure and Algorithms Course
Recent articles on Subarray
Recent articles on Subsequence
Recent articles on Subset




Reffered: https://www.geeksforgeeks.org


Arrays

Related
Implement Arrays in different Programming Languages Implement Arrays in different Programming Languages
Range Minimum Query with Range Assignment Range Minimum Query with Range Assignment
Suffix Product Array Suffix Product Array
Minimize Acceleration of Car to Cover Track Minimize Acceleration of Car to Cover Track
Contest Experience : Leetcode Weekly Contest #375 Contest Experience : Leetcode Weekly Contest #375

Type:
Geek
Category:
Coding
Sub Category:
Tutorial
Uploaded by:
Admin
Views:
18