Google OA For FTE
Anonymous User
2146

Google OA for FTE.

  1. Question related to prefx sums(Easy).

  2. 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.
    image

  3. 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.

Comments (9)