You are interviewing for a storage/infra-leaning role. Solve the following coding tasks and be ready to discuss time/space complexity and edge cases.
Given an integer array prices where prices[i] is the price of a stock on day i, compute the maximum profit achievable by choosing at most one buy day b and one sell day s with b < s. If no profit is possible, return 0.
prices: int[]
max_profit: int
1 <= n <= 2e5
, prices fit in 32-bit int
Follow-ups:
Given the root of a binary tree, return the list of node values visible when the tree is viewed from the right side (from top level to bottom level).
root
(binary tree node)
right_view: int[]
Follow-ups: