You are given three independent algorithmic tasks. For each one, explain your approach (no need to run code).
Given two sorted integer arrays A and B (non-decreasing order), merge them into a single sorted array containing all elements from both inputs.
A
,
B
0 <= len(A), len(B) <= 1e5
Given an array prices where prices[i] is the stock price on day i, compute the maximum profit you can achieve by choosing at most one day to buy and a later day to sell. If no profit is possible, return 0.
prices
1 <= n <= 1e5
,
0 <= prices[i] <= 1e9
Given a string s consisting only of the characters '(', ')', '[', ']', '{', '}', determine whether the parentheses/brackets are valid.
A string is valid if:
s
0 <= |s| <= 1e5