Arunb-lab1 / Hacktoberfest2022

This Repo is for new contributors who are just staring open source journey and #hacktoberfest #hacktoberfest2022
15 stars 78 forks source link

Vector of (min,max) ordered pairs for subarrays of a sequence #117

Closed HKRcodes closed 1 year ago

HKRcodes commented 1 year ago

Using this code, you can read a sequence of numbers and find the ordered pair (minimum value in subarray,maximum value in subarray) for the subarrays having user given size within the sequence length. WE will get a vector having these ordered pairs.

For better understanding, refer the output for this code for a user defined sequence of length 6 and subarray of size 3 :-

Please enter no of element : 6 Please enter the elements : 3 2 5 4 1 9 Please enter the size of sub array : 3

OutPut : { (2,5) (2,5) (1,5) (1,9) }

Here, first subarray(3,2,5) is taken and ordered pair(2,5) is got. Then, subarray(2,5,4) is taken and ordered pair(2,5) is got and so on. Each new subarray is considered by releasing the first element in the previous subarray and taking in the next element after the previous subarray.