Given an array A, find the size of the smallest subarray asked in MountainBlue, 2022

Problem Statement :

 Given an array A, find the size of the smallest subarray such that it contains at least one occurrence of the maximum value of the array and at least one occurrence of the minimum value of the array. Problem Constraints 1<= |A| <= 2000 Input Format The first line is the number of elements in an array. The second line is the space-separated array elements. f.e: 123 4 means A= [1, 2, 3, 4] Output Format Return the lengtlh of the smallest subarray which has at léasi pne occurrence of minimum and maximum eleknenbot the array Example Input Input 1: LAG27A...........


Comments

Popular posts from this blog

EV Minimize Array Cost asked in Infosys- march 2022 (available in c++ only)

Harry and Porter asked in MountainBlue ,2022

For e-learning, various tutorials are provided to the students.