LeetCode-Feedback / LeetCode-Feedback

675 stars 333 forks source link

Missing Test Case - 3254. Find the Power of K-Size Subarrays I #25375

Open Subhojit-Dey1234 opened 4 hours ago

Subhojit-Dey1234 commented 4 hours ago

LeetCode Username

thedumbsolver

Problem Number, Title, and Link

https://leetcode.com/problems/find-the-power-of-k-size-subarrays-i/description/?envType=daily-question&envId=2024-11-16

Bug Category

Missing test case (Incorrect/Inefficient Code getting accepted because of missing test cases)

Bug Description

All the test cases are passing and got accepted in spite of having a bug in the code.

Here is the test case used

nums = [13,8,63,64,65,66,67,11,3,3,11,200,201,202,203,204,1,13,11,3,7,10,10,7,11]
k = 5

Language Used for Code

C++

Code used for Submit/Run operation

class Solution {
public:
    int getTheSumOf(int n, int a){
        int x = 2*a + (n-1);
        int y = n*x;
        return y/2;
    }
    vector<int> resultsArray(vector<int>& nums, int k) {
        int n = nums.size();
        vector<int> prefixSum(n,0);

        vector<int> res(n-k+1, -1);
        prefixSum[0] = nums[0];
        for(int i = 1; i < n; i++) prefixSum[i] = prefixSum[i-1] + nums[i];

        for(int i = k-1; i < n; i++){
            int l = i-k;
            int a = getTheSumOf(k, nums[i-k+1]);

            int s = prefixSum[i];
            if(l >= 0) s -= prefixSum[l];

            if(s == a && nums[i] - nums[i-k+1] == k-1) res[i-k+1] = nums[i];
        }

        return res;
    }
};

Expected behavior

Code is failing on running which is correct but passing while submitting.

Screenshots

Screenshot 2024-11-16 at 8 21 23 AM Screenshot 2024-11-16 at 8 21 31 AM Screenshot 2024-11-16 at 8 27 03 AM

Additional context

No response

exalate-issue-sync[bot] commented 4 hours ago

LeetCode Support commented: Hello,

Your reported issue has been relayed to our team for thorough investigation. We appreciate your patience as we work to address and resolve this matter. We will reach out to you when we have updates regarding the issue.

If you have any further questions or concerns in the meantime, please feel free to let us know.

Best regards, LeetCode Support Team