Arjun - Daily Percentage Changes in Stock Prices
Single File Programming Question
Problem Statement
Arjun is working on a financial model that analyzes the daily percentage changes in stock prices. He wants to determine the maximum possible product of any contiguous sequence of changes to predict the highest potential growth. Your task is to help Arjun by implementing an algorithm that finds the contiguous subarray with the maximum product.
Input:
format :The first line of input consists of an integer n, representing the number of elements in the array. The second line contains n space-separated integers, representing the array arr of size n.
Output:
format :The first line of output prints an integer representing the maximum product of any contiguous subarray. Refer to the sample output for the formatting specifications. Code constraints : The given test cases fall under the following specifications: 1 ≤ n ≤ 20 -100 ≤ arr[i] ≤ 100 (for each element in the array) Sample test cases :
Input 1:
4 2 3 -2 4
Output 1 :
6
Input 2 :
5 -2 -3 0 -2 -40
Output 2 :
80