-
Notifications
You must be signed in to change notification settings - Fork 379
Description
LeetCode Username
Divyanshu_Ranjan_
Problem Number, Title, and Link
- Find the Minimum Amount of Time to Brew Potions
Bug Category
Problem examples, Incorrect test case (Output of test case is incorrect as per the problem statement)
Bug Description
For the problem "3494. Find the Minimum Amount of Time to Brew Potions," the following test case produces an incorrect output:
skill = [1, 5, 2, 4]
mana = [5, 1, 4, 2]
Actual Output:
88
Expected Output:
110
The solution returns 88, but according to the correct logic and calculations, the expected answer should be 110. Please review the output for this test case, as it does not match the expected result.
Language Used for Code
Java
Code used for Submit/Run operation
class Solution {
public long minTime(int[] skill, int[] mana) {
int n = skill.length;
int m = mana.length;
long[] end = new long[n]; // end[i] = when wizard i finishes current potion
long startTime = 0; // when the next potion can start
for (int j = 0; j < m; j++) {
long wizardStart = startTime;
for (int i = 0; i < n; i++) {
// Each wizard starts when both the potion has arrived and the wizard is free
wizardStart = Math.max(wizardStart, end[i]);
end[i] = wizardStart + (long) skill[i] * mana[j];
wizardStart = end[i];
}
startTime = end[0]; // wizard 0 can only start next potion after finishing current one
}
return end[n - 1]; // last wizard finishing last potion
}
}
Expected behavior
For the input:
skill = [1, 5, 2, 4]
mana = [5, 1, 4, 2]
the solution should correctly calculate the minimum amount of time to brew all potions, following the problem's requirements and constraints.
Based on valid logic and problem statement, the expected output is 110. This means that, when applying the optimal strategy described in the problem, the minimum total brewing time should be 110—not 88 as currently returned.
The solution should ensure that for this test case, the returned value matches the expected answer of 110.
Screenshots
No response
Additional context
No response