Company: Myntra
Difficulty: medium
Destroy All Monsters Problem Description You are playing a video game in which there are N number of monsters present and each monster has a specific power which is stored in an integer array A. Now, your goal is to defeat all the monsters. To successfully defeat all the monsters, certain guidelines must be followed. Only two monsters can clash at the same time. After the clash, energy cost is equal to the greatest common divisor (GCD) of their powers. You can only clash monsters whose position is the start, middle or end of the array. Your task is to find and return an integer value denoting the minimum total energy required to kill all the monsters. Note: The length of N is always even, so always take the second middle monster. Input Specification input1: An integer value N, denoting the total number of elements present in the array. input2: An integer Array A, denoting the power of each monster respectively. Output Specification Return an integer value denoting the minimum total ene