Posts

Showing posts from April, 2022

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...........

Harry and Porter asked in MountainBlue ,2022

                                                          Problem Statement   Harry and Potter choose a word string. Harry chose a number M  (less than the length of the string) and Potter chose N (less than the length of the string).  Harry will cut M letters from the end of the string, add them to the beginning and will give it to Potter. Then, Potter will also cut N letters from the end of the string,  add it to the beginning and give it to Harry. This process will continue till they get the original word string back.  For a given string and given values of M and N, find the number of turns in which they will get the original word string back . Example If the string is AbcDef, M= 1 and N = 2 the Output must be 4 4604  Explanation This is how the words tend will change. Abcbef > fAbcDe Dejbes- cDefAb AbcDef As there are 4 steps needed to bring the.....................

PERFECT SQUARE asked by MountainBlue

                                                              Perfect Square                                                         Problem Statement You're given an array A of size N, the task is to remove all the elements from the array except perfect squares of any integer and print the updated ay For example, if the given array is 9 12 16. Here, 9 and 16 are the perfect square of numbers 3 and 4 respectively. After removing others from the the t  Input Format: The input consists of two lines:  The first line contains an integer N denoting the size of an array A. The second line contains N integers separated by space denoting elements of the array A. The input will be read from the STDIN by the candidate Output Format:  Print the updated array with each element separated by space, if the updated array is empty then print -1. The output will benatched to the candidate's output printed on the STDOUT Constraints:   1< N < 500   • 1< A; S 50000 Example: Input: 100