Company: Infosys_
Difficulty: medium
Alternating Subsequence Maximum Problem Description You are given an array of integers. Your task is to find the maximum possible sum of an "alternating subsequence." The rules for forming this subsequence are specific: Only the maximum element of each "sign block" may be chosen. Blocks must be taken in order; alternation follows block order (positive → negative → positive → negative...). We may start from any block because cumulative sum resets (Kadane style). At least one element must be chosen. A single element is considered alternating, and you must select at least one element. Input Format The first line contains an integer, N , denoting the size of the array. Each line i of the N subsequent lines (where 0 ≤ i < N) contains an integer describing arr[i] . Constraints 1 -10^9 Examples Example 1 Input: 4 2 3 1 4 Output: 4 Explanation: [2, 3, 1, 4] -> all positive = a single positive block. Blocks: Block 1 (positive): max = 4 No negative block exists, so the only