Intuition
We are required to compute the number of bottles that is drinkable. A twist in the problem is that after every session of drinking all the bottles, we can exhange the empty bottles for more bottles (depending on the numExchange
).
Code
Python3
Big O Analysis
-
Runtime
The runtime complexity here is where
N = numBottles
since we would be iterating the entire sample set of number of bottles. -
Memory
The memory usage is since we are not using any extra data structure.
— A