This is essentially find all monotonically increasing subarrays of length k or greater. Can be done in O(n) time O(1) space if you iterate while i<j and stock[i] < stock[j]. Total result of increasing arrays on [i, j] is: max(0, j - i - k + 1), and continue iteration at j.
< and >, determine if each expression is balanced. If it's not, any > in expression[i] may be replaced with <> at most maxReplacements[i] times.It is feasible to run LC's balanced parantheses on each expression to check for balance. The hard part is determining if parts expression[i] can be swapped, and then check for balance. I could use any tips for determining swaps efficiently. I ran out of time while testing greedy swapping.
Return an array of length len(expression) where arr[i] is 0 if expression[i] is balanced/can be balanced with less than maxReplacements[i], or 1 if it is not possible to balance.