LeetCode-Feedback / LeetCode-Feedback

667 stars 327 forks source link

Missing Test Case - 523. Continuous Subarray Sum #24918

Open 00RohitRoshan opened 2 hours ago

00RohitRoshan commented 2 hours ago

LeetCode Username

rohitroshanjena2017

Problem Number, Title, and Link

https://leetcode.com/problems/continuous-subarray-sum/

Bug Category

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

Bug Description

[5,0,0,0] 3

5 is not a multiple of 3 but it expects true image

Language Used for Code

C++

Code used for Submit/Run operation

class Solution {
public:
    bool checkSubarraySum(vector<int>& nums, int k) {
        int n = nums.size();
        // map<int,int> mp;
        for(int i = 0; i<n; i++){
            int sum = 0;
            for(int j=i; j<n; j++){
                sum += nums[j];
                if(sum != 0 && sum%k == 0) return true;
            }
        }
        return false;
    }
};


### Expected behavior

[5,0,0,0]
3

As in this test case there is no possible subarray whose element sum is completely divisible by 3  

### Screenshots

_No response_

### Additional context

_No response_
exalate-issue-sync[bot] commented 2 hours ago

LeetCode Support commented: Hello rohitroshanjena2017,

Thank you for reaching out about the issue with the "Continuous Subarray Sum" problem. From your description, it seems there might be a slight misunderstanding related to the problem's definition of a "good subarray." According to the problem statement, a valid subarray must be of at least length two, and its sum must be a multiple of k. Importantly, 0 is considered a multiple of any integer due to the property that any number multiplied by zero remains zero.

Given the test case [5,0,0,0] with k=3, the subarray [0,0] satisfies the condition as its sum is 0, which is a multiple of 3. This is why the output is true. We recommend revisiting the problem statement and considering how subarrays containing zeros can affect the outcome.

If you have any further questions or need more clarification, please feel free to ask. We're here to help!

Best regards, LeetCode Support Team