Answer: Walmart Internship OA | 2 Nov
Answer · Posted Nov 2022
Approach We can simulate the whole process by brute force. First we allot the i candies to the first child, then out of remaining s-i candies we allot j to the second child. Now if the number of candies left are less than or equal to K we can allot the remaining candies to the third child and we get a valid allotment.Otherwise we get an invalid allotment. Time Complexity - O(K^2) Pseudocode ll ans=0; for(ll i(0);i<=min(s,k);++i){ // alloting to ...
The full answer & interview discussion are available to premium members.
Log in Create a free account