Program ini untuk menemukan elemen minimum dan maksimum dari array dapat diselesaikan dengan dua metode. Program ini dapat digunakan secara praktis Show Misalnya, seorang guru memiliki serangkaian nilai siswa dan perlu mendeklarasikan nilai tertinggi di kelas. Jadi program yang diberikan akan dengan mudah memberi guru nilai maksimum dalam larik Program $array[$i]) $min = $array[$i]; return $min; } // Main code $array = array( 10, 20, 30, 40, 50 ); echo (getMaxElement($array)); echo ("\n"); echo (getMinElement($array)); ?> Keluaran 50 10_ Program Larik PHP » Jika Anda ingin mendapatkan nilai minimum atau maksimum dari sebuah array, Anda dapat menggunakan fungsi min() atau max(). Berikut adalah skrip PHP tentang cara menggunakan min() dan max() "PHP", "One"=>"Perl", "Two"=>"Java"); print("Minimum string: ".min($array)."\n"); print("Maximum string: ".max($array)."\n"); ?> Skrip ini akan dicetak Minimum number: 1 Maximum number: 7 Minimum string: Java Maximum string: Perl Seperti yang Anda lihat, min() dan max() juga berfungsi untuk nilai string ⇒ Membuat Fungsi Anda Sendiri di PHP ⇐ Memisahkan String menjadi Array di PHP ⇑ Fungsi Bawaan PHP untuk Array ⇑⇑ Tutorial PHP Di blog ini, saya akan menunjukkan cara mendapatkan nilai minimum dan maksimum dari aaray di php. Fungsi "min()" mengembalikan nilai terendah dari array itu. Jika setidaknya dua parameter disediakan, min() mengembalikan yang terkecil dari nilai-nilai ini Fungsi max() mengembalikan nilai tertinggi dari array tersebut di php. Anda akan menemukan nilai maksimum dalam array
Diberikan array bilangan bulat positif dan negatif, tugasnya adalah menghitung jumlah elemen minimum dan maksimum dari semua sub-array berukuran k Contoh. Input : arr[] = {2, 5, -1, 7, -3, -1, -2} K = 4 Output : 18 Explanation : Subarrays of size 4 are : {2, 5, -1, 7}, min + max = -1 + 7 = 6 {5, -1, 7, -3}, min + max = -3 + 7 = 4 {-1, 7, -3, -1}, min + max = -3 + 7 = 4 {7, -3, -1, -2}, min + max = -3 + 7 = 4 Missing sub arrays - {2, -1, 7, -3} {2, 7, -3, -1} {2, -3, -1, -2} {5, 7, -3, -1} {5, -3, -1, -2} and few more -- why these were not considered?? Considering missing arrays result coming as 27 Sum of all min & max = 6 + 4 + 4 + 4 = 18_ Direkomendasikan. Harap coba pendekatan Anda pada {IDE} terlebih dahulu, sebelum melanjutkan ke solusi Masalah ini terutama merupakan perpanjangan dari masalah di bawah ini. Metode 1 (Sederhana). Jalankan dua loop untuk menghasilkan semua subarray berukuran k dan temukan nilai maksimum dan minimum. Terakhir, kembalikan jumlah semua elemen maksimum dan minimum. Metode 2 (Efisien menggunakan Dequeue). Idenya adalah menggunakan struktur data Dequeue dan konsep sliding window. Kami membuat dua antrian ujung ganda kosong ukuran k ('S', 'G') yang hanya menyimpan indeks elemen jendela saat ini yang tidak berguna. Suatu elemen tidak berguna jika tidak dapat maksimum atau minimum dari subarray berikutnya. a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k. Di bawah ini adalah implementasi dari ide di atas C++
a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.0 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.1 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.2 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.1 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.4 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.1 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.6 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.1 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.8 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k._9 140 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.1 142 143
140 145 140 147 140 149 140 // C++ program to find sum of all minimum and maximum 1140 // C++ program to find sum of all minimum and maximum 3140 // C++ program to find sum of all minimum and maximum 1140 // C++ program to find sum of all minimum and maximum 7a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.1 // C++ program to find sum of all minimum and maximum 9
140 // elements Of Sub-array Size k. 1140 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.1 // elements Of Sub-array Size k. 4140 // elements Of Sub-array Size k. 6 // elements Of Sub-array Size k. 7140 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.9
________353 $array[$i]) $min = $array[$i]; return $min; } // Main code $array = array( 10, 20, 30, 40, 50 ); echo (getMaxElement($array)); echo ("\n"); echo (getMinElement($array)); ?>_353_______3
________353 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k._353_______8 #include<bits/stdc++.h> 9
________353 $array[$i]) $min = $array[$i]; return $min; } // Main code $array = array( 10, 20, 30, 40, 50 ); echo (getMaxElement($array)); echo ("\n"); echo (getMinElement($array)); ?>_354_______3
140 namespace 7
140 namespace 9140 // elements Of Sub-array Size k. 6 std; 2140 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.9 ________353 $array[$i]) $min = $array[$i]; return $min; } // Main code $array = array( 10, 20, 30, 40, 50 ); echo (getMaxElement($array)); echo ("\n"); echo (getMinElement($array)); ?>_356_______6
________353 $array[$i]) $min = $array[$i]; return $min; } // Main code $array = array( 10, 20, 30, 40, 50 ); echo (getMaxElement($array)); echo ("\n"); echo (getMinElement($array)); ?>_357_______2
a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.01
a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.04
a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.06
a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.08
a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.10
________353 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k._353_______8 #include<bits/stdc++.h> 9
a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.18
a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.20
140 namespace 7
140 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.36 140 // Returns sum of min and max element of all subarrays 2
140 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.40 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.41
a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k._43 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.1 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.45 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k._9 140 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.1 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.49 140 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.1 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.52 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.53 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.54 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.53 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.56 140 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.1 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.59 140 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.61 140 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.40 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.64
Jawaa) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k._66
a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.68 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.69 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.68 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.71 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.72 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.73 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.74
140 // Returns sum of min and max element of all subarrays 140 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.0 140 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.72 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.81 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.1 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.2 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.1 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.4 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.1 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.8 140 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.9
a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.1 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.92 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.93 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.94 143 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k._96
145 ________353 $array[$i]) $min = $array[$i]; return $min; } // Main code $array = array( 10, 20, 30, 40, 50 ); echo (getMaxElement($array)); echo ("\n"); echo (getMinElement($array)); ?>_16_______7 ________353 $array[$i]) $min = $array[$i]; return $min; } // Main code $array = array( 10, 20, 30, 40, 50 ); echo (getMaxElement($array)); echo ("\n"); echo (getMinElement($array)); ?>_16_______9 ________353 $array[$i]) $min = $array[$i]; return $min; } // Main code $array = array( 10, 20, 30, 40, 50 ); echo (getMaxElement($array)); echo ("\n"); echo (getMinElement($array)); ?>_351_______1
________353 $array[$i]) $min = $array[$i]; return $min; } // Main code $array = array( 10, 20, 30, 40, 50 ); echo (getMaxElement($array)); echo ("\n"); echo (getMinElement($array)); ?>_351_______1
1410 1411 1412 1411 1414
a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.1 1419 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.93 1421
1424 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.93 1426
a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.9
1435 14_36 1437 #include<bits/stdc++.h> 9a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k._96
1446 14_36 1448 #include<bits/stdc++.h> 9a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k._96
1454
1456
a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k._96 ________353 $array[$i]) $min = $array[$i]; return $min; } // Main code $array = array( 10, 20, 30, 40, 50 ); echo (getMaxElement($array)); echo ("\n"); echo (getMinElement($array)); ?>_355_______9
1464
a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.9
1474 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k._96
1482 14_36 1484
1487 14_36 1489 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k._96
a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.08
a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.10
1435 14_36 1437 #include<bits/stdc++.h> 9a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k._96
a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.18
a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.20
1446 14_36 1448 #include<bits/stdc++.h> 9a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k._96
1454
1456
a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k._96
a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.36 ________353 $array[$i]) $min = $array[$i]; return $min; } // Main code $array = array( 10, 20, 30, 40, 50 ); echo (getMaxElement($array)); echo ("\n"); echo (getMinElement($array)); ?>_16_______74 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k._96
a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.40 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.41 140 namespace 7
140 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.72 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.81 // C++ program to find sum of all minimum and maximum 35 // C++ program to find sum of all minimum and maximum 36140 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.9
a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.1 // C++ program to find sum of all minimum and maximum 41// C++ program to find sum of all minimum and maximum 42// C++ program to find sum of all minimum and maximum 43// C++ program to find sum of all minimum and maximum 44// C++ program to find sum of all minimum and maximum 45// C++ program to find sum of all minimum and maximum 46// C++ program to find sum of all minimum and maximum 43// C++ program to find sum of all minimum and maximum 48// C++ program to find sum of all minimum and maximum 45// C++ program to find sum of all minimum and maximum 50// C++ program to find sum of all minimum and maximum 45// C++ program to find sum of all minimum and maximum 46// C++ program to find sum of all minimum and maximum 45// C++ program to find sum of all minimum and maximum 42// C++ program to find sum of all minimum and maximum 55
a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.1 // C++ program to find sum of all minimum and maximum 58// C++ program to find sum of all minimum and maximum 501421
140 namespace 7
Piton
a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.68 // C++ program to find sum of all minimum and maximum 72
140 // C++ program to find sum of all minimum and maximum 78 // C++ program to find sum of all minimum and maximum 79 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.93 // C++ program to find sum of all minimum and maximum 81
140 // C++ program to find sum of all minimum and maximum 83140 // C++ program to find sum of all minimum and maximum 85140 // C++ program to find sum of all minimum and maximum 87140 // C++ program to find sum of all minimum and maximum 89140 // C++ program to find sum of all minimum and maximum 91140 // C++ program to find sum of all minimum and maximum 89140 // C++ program to find sum of all minimum and maximum 95// C++ program to find sum of all minimum and maximum 79 // C++ program to find sum of all minimum and maximum 97140 // C++ program to find sum of all minimum and maximum 99// C++ program to find sum of all minimum and maximum 79 // C++ program to find sum of all minimum and maximum 97
140 // elements Of Sub-array Size k. 03
140 // elements Of Sub-array Size k. 6 // elements Of Sub-array Size k. 06// elements Of Sub-array Size k. 07 // elements Of Sub-array Size k. 08// elements Of Sub-array Size k. 09
________353 $array[$i]) $min = $array[$i]; return $min; } // Main code $array = array( 10, 20, 30, 40, 50 ); echo (getMaxElement($array)); echo ("\n"); echo (getMinElement($array)); ?>_352_______14
________353 $array[$i]) $min = $array[$i]; return $min; } // Main code $array = array( 10, 20, 30, 40, 50 ); echo (getMaxElement($array)); echo ("\n"); echo (getMinElement($array)); ?>_352_______52 ________353 $array[$i]) $min = $array[$i]; return $min; } // Main code $array = array( 10, 20, 30, 40, 50 ); echo (getMaxElement($array)); echo ("\n"); echo (getMinElement($array)); ?>_352_______54
140 // elements Of Sub-array Size k. 58________16______0
________353 $array[$i]) $min = $array[$i]; return $min; } // Main code $array = array( 10, 20, 30, 40, 50 ); echo (getMaxElement($array)); echo ("\n"); echo (getMinElement($array)); ?>_352_______69
a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.93 // elements Of Sub-array Size k. 78// elements Of Sub-array Size k. 74 // elements Of Sub-array Size k. 42a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.93
________353 $array[$i]) $min = $array[$i]; return $min; } // Main code $array = array( 10, 20, 30, 40, 50 ); echo (getMaxElement($array)); echo ("\n"); echo (getMinElement($array)); ?>_352_______86
________353 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k._353_______02
________353 $array[$i]) $min = $array[$i]; return $min; } // Main code $array = array( 10, 20, 30, 40, 50 ); echo (getMaxElement($array)); echo ("\n"); echo (getMinElement($array)); ?>_353_______20 ________353 $array[$i]) $min = $array[$i]; return $min; } // Main code $array = array( 10, 20, 30, 40, 50 ); echo (getMaxElement($array)); echo ("\n"); echo (getMinElement($array)); ?>_353_______22
________353 $array[$i]) $min = $array[$i]; return $min; } // Main code $array = array( 10, 20, 30, 40, 50 ); echo (getMaxElement($array)); echo ("\n"); echo (getMinElement($array)); ?>_352_______52 ________353 $array[$i]) $min = $array[$i]; return $min; } // Main code $array = array( 10, 20, 30, 40, 50 ); echo (getMaxElement($array)); echo ("\n"); echo (getMinElement($array)); ?>_352_______54
140 #include<bits/stdc++.h> 66________16______0 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.93 // elements Of Sub-array Size k. 78// elements Of Sub-array Size k. 74 ________352______42________5______35__8
140 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.40 // C++ program to find sum of all minimum and maximum 78
C#
a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.73 using 20a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k._9
a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.96 // Returns sum of min and max element of all subarrays a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.96 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.0 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.96 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.72 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.81 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.1 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.2 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.1 using 32a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.1 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.8 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.96 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.9 140 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.1 142 143
140 145 140 147 140 149 140 // C++ program to find sum of all minimum and maximum 1140 // C++ program to find sum of all minimum and maximum 3140 // C++ program to find sum of all minimum and maximum 1________16______0 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.1 using 561411 using 54a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.1 using 60________16______0 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.1 using 641411 using 54a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.1 using 60
140 // elements Of Sub-array Size k. 1140 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.1 // elements Of Sub-array Size k. 4140 // elements Of Sub-array Size k. 6 // elements Of Sub-array Size k. 7140 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.9
________354 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k._355_______02 ________354 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k._355_______04 140 namespace 7
140 namespace 9140 // elements Of Sub-array Size k. 6 namespace 11140 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.9
________354 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k._355_______21
________353 $array[$i]) $min = $array[$i]; return $min; } // Main code $array = array( 10, 20, 30, 40, 50 ); echo (getMaxElement($array)); echo ("\n"); echo (getMinElement($array)); ?>_355_______30 ________354 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k._353_______5 namespace 33
a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.08
a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.10 ________354 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k._353_______5 namespace 42
a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.18
a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.20
________354 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k._355_______02 ________354 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k._355_______04 140 namespace 7
140 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.36 140 namespace 67140 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.40 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.41 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.96 namespace 7
a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.96 namespace 74a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.96 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.72 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.81 // C++ program to find sum of all minimum and maximum 35 namespace 79a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.96 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.9 140 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.1 namespace 84140 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.1 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.59 140 namespace 89a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.96 namespace 7
Javascript
a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.0
a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k._9 140 std; 03143
140 145 140 147 140 149 140 // C++ program to find sum of all minimum and maximum 1140 std; 14140 // C++ program to find sum of all minimum and maximum 1140 std; 18140 std; 20
140 // elements Of Sub-array Size k. 1140 std; 24140 // elements Of Sub-array Size k. 6 // elements Of Sub-array Size k. 7140 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.9
140 #include<bits/stdc++.h> 1140 #include<bits/stdc++.h> 3140 #include<bits/stdc++.h> 5 std; 36
140 using 1140 using 3140 #include<bits/stdc++.h> 5 std; 46
140 namespace 1140 std; 53140 std; 55140 namespace 7
140 namespace 9140 // elements Of Sub-array Size k. 6 std; 62140 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.9
140 std; 6140 std; 8140 // Returns sum of min and max element of all subarrays 0140 namespace 21
140 // Returns sum of min and max element of all subarrays 4140 // Returns sum of min and max element of all subarrays 6140 #include<bits/stdc++.h> 5 std; 79________353 $array[$i]) $min = $array[$i]; return $min; } // Main code $array = array( 10, 20, 30, 40, 50 ); echo (getMaxElement($array)); echo ("\n"); echo (getMinElement($array)); ?>_356_______81 140 #include<bits/stdc++.h> 5 std; 84
140 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.08 140 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.10 140 #include<bits/stdc++.h> 5 std; 93
140 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.18 140 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.20 140 #include<bits/stdc++.h> 5 std; 46
140 namespace 1140 std; 53140 std; 55140 namespace 7
140 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.36 140 namespace 21140 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.40 a) In deque 'G', we maintain decreasing order of values from front to rear b) In deque 'S', we maintain increasing order of values from front to rear 1) First window size K 1.1) For deque 'G', if current element is greater than rear end element, we remove rear while current is greater. 1.2) For deque 'S', if current element is smaller than rear end element, we just pop it while current is smaller. 1.3) insert current element in both deque 'G' 'S' 2) After step 1, front of 'G' contains maximum element of first window and front of 'S' contains minimum element of first window. Remaining elements of G and S may store maximum/minimum for subsequent windows. 3) After that we do traversal for rest array elements. 3.1) Front element of deque 'G' is greatest and 'S' is smallest element of previous window 3.2) Remove all elements which are out of this window [remove element at front of queue ] 3.3) Repeat steps 1.1 , 1.2 ,1.3 4) Return sum of minimum and maximum element of all sub-array size k.41
140 // Returns sum of min and max element of all subarrays 25140 // Returns sum of min and max element of all subarrays 27140 // Returns sum of min and max element of all subarrays 29
Keluaran 14 Kompleksitas Waktu. Pada) Artikel ini disumbangkan oleh Nishant_Singh (Pintu). Jika Anda menyukai GeeksforGeeks dan ingin berkontribusi, Anda juga dapat menulis artikel menggunakan tulis. geeksforgeeks. org atau kirimkan artikel Anda ke review-team@geeksforgeeks. org. Lihat artikel Anda muncul di halaman utama GeeksforGeeks dan bantu Geeks lainnya Bagaimana menemukan nilai maksimum array di PHP?Fungsi max() mengembalikan nilai tertinggi dalam larik, atau nilai tertinggi dari beberapa nilai yang ditentukan.
Bagaimana Anda menemukan nilai min dan maks dalam array?Fungsi getresult( int arr[],int n) adalah untuk menemukan elemen maksimum dan minimum yang ada dalam array dengan no minimum. perbandingan. Jika hanya ada satu elemen maka kita akan menginisialisasi variabel max dan min dengan arr[0]. Untuk lebih dari satu elemen, kami akan menginisialisasi max dengan arr[1] dan min dengan arr[0].
Bagaimana menemukan nilai minimum array di PHP?Fungsi min() mengembalikan nilai terendah dalam larik, atau nilai terendah dari beberapa nilai yang ditentukan.
Bagaimana Anda menemukan nilai maks dalam array?Untuk menemukan elemen terbesar dari array, cara sederhananya adalah mengatur elemen dalam urutan menaik . Setelah disortir, elemen pertama akan mewakili elemen terkecil, elemen berikutnya akan menjadi elemen terkecil kedua, dan seterusnya, elemen terakhir akan menjadi elemen terbesar dari array. |