Company: ARCESIUM

Difficulty: medium

Problem Statement

# Maximum-Sum Bitonic Subarray You are given an array `A` of `N` integers. A bitonic subarray is a contiguous subarray that strictly increases to one peak and then strictly decreases. A valid bitonic subarray must contain at least one increasing adjacent pair and at least one decreasing adjacent pair. Print the maximum possible sum of a valid bitonic subarray. If none exists, print `0`. ## Input Format - The first line contains `N`. - The second line contains `N` space-separated integers `A[i]`. ## Output Format Print the maximum sum, or `0` if no valid bitonic subarray exists. ## Constraints - `1 <= N <= 1000` - `-100000 <= A[i] <= 100000` - The answer fits in a signed 64-bit integer. ## Example 1 Input: 5 1 3 5 4 2 Output: 15 ## Example 2 Input: 6 1 2 6 5 4 8 Output: 18 Explanation: The maximum-sum bitonic subarray is `1 2 6 5 4`. ## Example 3 Input: 4 1 2 3 4 Output: 0 ## Example 4 Input: 4 5 4 3 2 Output: 0 ## Example 5 Input: 6 -5 -2 3 7 4 1 Output: 15 Explanation: The

More ARCESIUM OA questionsInterview experiences