Nutanix || Onsite || 2021
Anonymous User
1561

There are n houses in a row. The houses are indexed from 1 – n. Each house has some amount of money associated with it and you are given the values in an array. Now a volunteer has to collect money for some NGOs. There are 2 ways in which a volunteer can collect money:

The volunteer can collect money in any order of houses.
The volunteer can collect money only from consecutive houses.
Now there are 3 NGOs. Any volunteer that distributes an equal amount of money to all three NGOs is eligible for an award. We need to find the maximum number of volunteers that are eligible for an award. It is given that multiple volunteers can collect money from the same house but one volunteer cannot collect money from the same house multiple times.

Given this premise, there were 4 questions asked one by one:

  1. Find the maximum number of volunteers that will be awarded if all volunteers can collect money in only the first way.

  2. Find the maximum number of volunteers that will be awarded if all volunteers can collect money in only the second way.

  3. Find the maximum number of volunteers that will be awarded if all volunteers can collect money in only the second way given that there are queries of the form (l, r) such that you can only consider houses in the range [l, r]. The number of queries was up to 10 ^ 5.

  4. The last follow-up was that in the previous question, we can now have queries of the form (index, val) which means change value of the house at the index to val.

Comments (1)