LeetCode-Feedback / LeetCode-Feedback

662 stars 315 forks source link

[BUG] - Incorrect test case for 636 Exclusive Time of Function #22581

Closed gui0506 closed 3 weeks ago

gui0506 commented 3 months ago

LeetCode Username

gui0506

Problem Number, Title, and Link

  1. Exclusive Time of Function https://leetcode.com/problems/exclusive-time-of-functions/description/

Bug Category

Incorrect test case (Output of test case is incorrect as per the problem statement)

Bug Description

Test case 121 is incorrect and should be removed or changed

The log should never have "0:end:6" before function 1 finishes, because we are running function 1 currently. The test case makes no sense at all. A possible fix is to change "0:end:6","1:end:7" to "1:end:6","0:end:7"

Language Used for Code

Java

Code used for Submit/Run operation

class Solution {
    public int[] exclusiveTime(int n, List<String> logs) {
        int[] solution = new int[n];
        Deque<int[]> stack = new ArrayDeque<>();
        for (String log: logs) {
            String[] parts = log.split(":");
            int function = Integer.valueOf(parts[0]);
            int time = Integer.valueOf(parts[2]);
            if (parts[1].equals("start")) {
                stack.push(new int[]{function, time});
            }
            else { // end
                int[] start = stack.pop();
                int duration = time - start[1] + 1;
                solution[function] += duration;
                if (stack.size() > 0) {
                    int lastFunction = stack.peek()[0];
                    solution[lastFunction] -= duration;
                } 
            }
        }

        return solution;
    }
}

Expected behavior

The test case makes no sense at all. A possible fix is to change the test case from "0:end:6","1:end:7" to "1:end:6","0:end:7"

Screenshots

No response

Additional context

No response

tsunghuanghsieh commented 2 months ago

22693 Duplicate.

exalate-issue-sync[bot] commented 3 weeks ago

Epiphania_Ekenimoh commented: Hello there,

The issue you reported has been resolved. Please feel free to verify.

We apologize for any inconvenience this may have caused and appreciate your patience while we worked to resolve the issue. If you have any further questions or concerns, please do not hesitate to contact us.

Thank you, LeetCode Support Team