
Ninja and Chocolates Problem Statement
Ninja is hungry and wants to eat his favorite chocolates, but his mother won't let him because he has already eaten enough. There are 'N' jars filled with chocolates. His mother has gone to the market and will return after 'M' minutes. The ninja can eat up to 'X' chocolates per minute. Each minute, he picks any jar and eats 'X' chocolates from it. If a jar has less than 'X', he consumes all chocolates available in that jar for that minute and stops eating more during that minute. Your goal is to determine 'X', the minimum eating speed to consume all chocolates within 'M' minutes, before his mother returns.
Input:
The first line contains an integer 'T' indicating the number of test cases.
Each test case consists of:
- The first line: two space-separated integers 'N' and 'M' (number of jars and minutes until the mother returns).
- The second line: 'N' space-separated integers representing the number of chocolates in each jar.
Output:
For each test case, output a single integer 'X', the minimum chocolate-eating speed required. Output results for each test case on a new line.
Example:
Input:
2
3 5
4 3 7
5 6
3 2 1 9 5
Output:
4
5
Constraints:
1 ≤ T ≤ 5
1 ≤ N ≤ 10^6
N ≤ M ≤ 10^9
1 ≤ chocolates[i] ≤ 10^9
- Time limit: 1 second
Note:
You do not need to print anything yourself; simply implement the required function.


Find the minimum eating speed required for a ninja to consume all chocolates within a given time limit.
Iterate through possible eating speeds to find the minimum speed that allows the ninja to consume...read more

Top Salesforce Software Developer interview questions & answers
Popular interview questions of Software Developer
Top HR questions asked in Salesforce Software Developer
Reviews
Interviews
Salaries
Users/Month