NetApp | SDE | 24 December
Question · Posted Apr 2020
Given infinite coins, and 3 pockets, we have to put the coins in 3 pockets, such that the sum of all coins is in the range [X,Y] inclusive. Find number of ways to put the coins. Input will be in range X,Y. Input: [4,5] [X=4, Y=5] Output: 9 (3+6) total coins = 4. Number of ways = 3 {1,1,2} {1,2,1} {2,1,1} total coins = 5. No of ways = 6 {1,1,3} {1,3,1} {3,1,1} {1,2,2} {2,1,2} {2,2,1}
The full answer & interview discussion are available to premium members.
Log in Create a free account