You are given three independent coding tasks (solve each one). Unless otherwise stated, implement a function with the described input/output.
Given an array heights of length n where heights[i] is the height of the i-th person standing in a line (from left to right). For each person i, compute how many people to the right are visible to person i.
A person j > i is visible to i if:
k
with
i < k < j
,
heights[k] < min(heights[i], heights[j])
.
Return an array ans of length n where ans[i] is the number of visible people to the right of i.
Constraints (typical): 1 <= n <= 1e5, 1 <= heights[i] <= 1e9.
Given an integer n, generate all strings containing exactly n pairs of parentheses that are balanced.
Return the list of valid strings in any order.
Constraints (typical): 0 <= n <= 10.
Given a string s consisting of lowercase letters and parentheses '(' and ')', remove the minimum number of parentheses so that the resulting string is a valid parentheses string (letters are always allowed and do not affect validity).
Return any valid result after minimum removals.
A parentheses string is valid if parentheses are balanced and properly nested.
Constraints (typical): 1 <= |s| <= 1e5.