Medallia Argentina Inter 1 minutes Question - 1 Field fencing A rectangular field is to be fenced. The north side is meters long and the area of the field is 68 squared meters. How many meters of fencing will be required, if we were to fence all but the north side? 4 68 88 18 Question - Q, R & T Q is as much younger than R as he is older than T. If the sum of the ages of R and T is 5 years, what is definitely the difference between R and Q's age? 1 year years 5 years Data inadequate None of these Question - 4 children group You have to select 4 children from a group of 6 boys and 4 girls. In how many ways can this be done such that at least 1 boy is part of the selected group (without taking the order into account)? 159 194
5 9 Question - 4 Anagram Party We are given a word and n phrases. We need to find out how many anagrams of that word exist in each phrase. 1 n 1 word 1 All words are lowercase Special character other than letters and numbers are: spaces, dot, comma. Complete a function named amountofanagrams which takes a single string (word) and an array of strings (phrases) as parameters. Return an integer array denoting the amount of anagrams in each phrase. word word is drow when dwor nothing to see here Sample Input dormitory dirty room dirtyroom room is dirty Sample Output 1 Question - 5 Climbing stairs
You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb 1 or steps. In how many distinct ways can you climb to the top? 1 n Complete a function named waystoclimb which takes a single integer (n) as a parameter. Return a single integer denoting the amount of distinct ways to climb the n stairs. Explanation Sample 1 You can climb stairs in two different ways: [1, 1] or []. Sample Input 1 Sample Output 89 Question - 6 IronMan IronMan is ready for battle! He starts his battle at location moves in 1-unit increments toward his final showdown at location n 1. Each location i has a power value, p. i If p i <, then there is an enemy at location i that he must lose p i power to beat; if p i, then he will restore p i power at location i. IronMan dies if his armor charge becomes < 1 at any point either during or after a fight, so he needs a proper initial charge to survive all possible fights in his battle traveling from location to location n 1. Help him find the minimum charge needed to survive all fights in the battle! Complete the ironman function in your editor. It has 1 parameter: an array of n integers, p, where each index i ( i < n) describes the power charge lost or gained at battle location i. If the value at some p i <, it represents the amount of charge IronMan must deplete to defeat the enemy; otherwise, it represents the amount of charge that he can restore at that location. Your function must return an integer denoting the minimum starting charge IronMan needs to survive all fights. The locked stub code in your editor reads the following input from stdin and passes it to your function: The first line contains an integer, n, denoting number of
locations IronMan will pass through. Each line i of the n subsequent lines (where i < n) contains an integer describing the amount of charge he will gain or lose at battle location i. 1 n 15 1 pi 1 Your function must return an integer denoting the minimum amount of charge IronMan will need to survive all fights in the battle. This is printed to stdout by the locked stub code in your editor. Sample Input The following argument is passed to your function: p = {-5, 4, -,, 1, -1, -6, -1,, 5} Sample output 8 The following argument is passed to your function: p = { 5,4,,, 1} Sample output 1 6 Sample Input The following argument is passed to your function: p = { 5, 4,,, 1, 1, 6, 1,, 5} Sample Output 1 Explanation Sample Case : If IronMan's initial charge < 8, then he will die somewhere in the middle of his battle. Thus, we return 8 as the minimum charge needed to survive the battle. Question - 7 Two operations You are given only two operations, ADD_1 and MULTIPLY_. You start from and using the two operations reach a number N. Find the least number of operations needed to do this. : The first line will contain an integer T that gives the number of test cases. There will be one integer N on each of the following T lines. Return an integer array denoting the minimum number of operations needed in each test case.
T 1, N 1 16 Sample Input 5 Sample Output 4 Explanation Case1: To reach 5 from. We do ADD1 then Multiply two times and then add 1 again, total 4 steps Case: To reach from. We can either do Add 1 times or Add 1, multiply and again add 1 Question - 8 Array Game Jessica has an array, numbers, consisting of n integers. She plays a game with this array where, in each move, she selects (n 1) elements and increments their values by one. For example, if n = 4, she chooses of the 4 elements during each move and increments each of their values by one. Jessica wants to know the minimum number of moves required to make all of the array's elements equal. Complete the countmoves function in your editor. It has 1 parameter: an array of integers, numbers. It must return a long integer denoting the minimum number of moves required for all elements to be equal. The locked stub code in your editor reads the following input from stdin and passes it to your function: The first line contains an integer, n, denoting the size of the numbers array. Each line i of the n subsequent lines (where i < n) contains an integer describing numbers. i 5 1 n 1 6 1 numbers i 1, where numbers i is th the i element of the numbers array. Your function must return a long integer denoting the minimum number of moves required for Jessica to make all elements of the array equal. This is printed to stdout by the locked stub code in your editor. 1
Explanation 1 Initially, numbers = [1,, ]. Jessica makes the following moves: 1. Increments the values corresponding to indices in the set {, 1}, so the array becomes [,, ].. Increments the values corresponding to indices in the set {, 1}, so the array becomes [, 4, ].. Increments the values corresponding to indices in the set {, }, so the array becomes [4, 4, 4]. Recall that the set of indices updated during each move must be of size n 1. It took a minimal three moves to make all elements in the array equal, so we return. Sample Input Sample Output Explanation Initially, numbers = [,, ]. Because all of its elements are already equal, no moves are required and we return. Question - 9 Fun with palindromes Problem Statement A palindrome is a word, phrase, number, or other sequence of characters which reads the same forward and backwards. For example: "madam" and "dad" are palindromes, but "sir" and "sad" are not. The fun score for two subsequences(not substrings), A and B, in string s is the product of their respective lengths. There are many ways to choose A and B, but your goal is to maximize the fun score. There can't be any overlap or crossover between the two subsequences. Given string s, select exactly two non-overlapping noncrossing-over palindromic subsequences, A and B, from s to maximize the fun score. Non crossing over means that given the string aababb, you can't get aaa and bbb, since the subsequences cross over.
1 < s s is composed of lowercase English characters. Complete a function named funpal which takes a single string (s) as a parameter. Return a single integer denoting the maximum possible fun score for s. Sample Input acdapmpomp Sample Output 15 axbawbaseksqke 5 Explanation Sample Case You can select A= aca and B= pmpmp. The product is * 5 = 15, so we return 15. Sample Case 1 You can select A= ababa and B= ekske. The product is 5 * 5 = 5, so we print 5. Another possible solution is A= ababa and B= ekqke which also yields the answer 5.