-
You are given an array Arr of N integers. You need to find the length of longest Peak Subarray of the given array Arr.
Input Format:
Peak Array: Array A of length K is called as a peak Array, if following condition holds true:
A[1]<A[2]<A[3]<….<A[K].
Formally any strictly increasing array is called a Peak Array.
Subarray: Subarray of any array is a contiguous part of the array (with length greater than zero).
Your task is to find the length of the longest peak subarray of a given array.
Note: Array of length 1 is always a Peak Array.
First line of input, single integer value N
Output Format:
Second line of input, contains N integers with space-separation for Array Arr.
Print an integer that represents the length of longest peak subarray.
Sample Input:
5
3 3 9 8 4
Sample Output:
2
-
Suppose, for a stock, we have a series of N daily price quotes. For each day, the task is to find how many such continuous days (including current day) are there prior to the current day where the price of the stock was less than or equal to the price on the current day.
Hint: Start counting continuously from the current day to all days before it; stop when the stock is higher than the current day.
For example, 6 day’s stock prices are as follows: {100, 60, 70, 65, 80, 85}Day 1 2 3 4 5 6 Stock Price 100 60 70 65 80 85 Output 1 1 2 1 4 5
First input, the candidate has to write the code to accept a single integer value N denoting the number of days.
Output Format:
Second input, the code should accept N number of integer values separated by a space.
Output should be N integer values from the list separated by a single space character.
Constraints:
2 <= N <= 100 0 <= L[i] <= 100000
Sample Input:
6
100 60 70 65 80 85
Sample Output:
1 1 2 1 4 5