Amazon| OA2| New Grad
Anonymous User
1005

First Question:
Find the number of all subsequences with K distinct characters of a string.

Second Question:
Given a n-nary tree with integer values, calculate the average value of every subtree with more than one node and return the maximum.
For example:
200
100 150
50 40 30 20 80
There are three subtrees with more than one node in the tree, and the average values of them are:
200: (200 + 100 + 50 + 40 + 150 + 30 + 20 + 80) / 8 = 670 / 8
100: (100 + 50 + 40) / 3 = 190 / 3
150: (150 + 30 + 20 + 80) / 4 = 280 / 4

Comments (1)