Compute tree right view and target-sum subarrays | Meta Interview Question