Google OA for FTE.
Question related to prefx sums(Easy).
Given a tree and values(B[i]) for each node in the tree, find for every node, the least non-negative integer that does not occur in its subtree. N<=10^5, B[i] <= 10^9.

Given an array of 0, 1, and 2's find the minimum number of swaps to be performed such that A[i] = i%3 (0 <= i <= n-1) for all i. If it is not possible return -1. N <= 10^5.
Please share ideas for problem 2 and 3. Thank you.