Company: Infosys_
Difficulty: medium
Alternating Subsequence Maximum Problem Description You're given an array of integers, and the goal is to find the largest possible sum obtainable from an "alternating subsequence," built under these specific rules: You may only pick the maximum element from within each "sign block." Blocks must be taken in the order they occur, and picks must alternate by block sign (positive → negative → positive → negative...). You're free to begin at any block, since the running total resets at each new start (Kadane-style). At least one element has to be picked. A lone element counts as a valid alternating subsequence, and picking at least one is mandatory. 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] -> every value is positive, so this forms one single