LeetCode-Feedback / LeetCode-Feedback

666 stars 323 forks source link

[BUG] - <title> 567 , last Testcase not getting accepted #24611

Open abdmankhan opened 3 days ago

abdmankhan commented 3 days ago

LeetCode Username

v2khan

Problem Number, Title, and Link

567 https://leetcode.com/problems/permutation-in-string/description/?envType=daily-question&envId=2024-10-05

Bug Category

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

Bug Description

image image

the same test case is getting accepted in user testcases section whereas it is throwing TLE while submission.

Language Used for Code

C++

Code used for Submit/Run operation

class Solution {
public:
    bool checkInclusion(string s1, string s2) {

        unordered_map<char, int> hash;
        for(auto i : s1){
            hash[i]++;
        }
        int i = 0, n = s2.length();
        while(i < n){
            if(hash.find(s2[i]) == hash.end()) {
                i++;
                continue;
            }
            int lastI = i;
            unordered_map<char, int> temp = hash;
            bool status = true;
            while(!temp.empty()){
                if(temp.find(s2[i]) == temp.end()){
                    status = false;
                    break;
                }
                temp[s2[i]]--;
                if(temp[s2[i]] == 0) temp.erase(s2[i]);
                i++;
            }
            if(status == false){ 
                i = lastI + 1;
                continue;
            }
            else return true;
        }
        return false;
    }
};

Expected behavior

it should be submitted when the result is correct.

Screenshots

No response

Additional context

No response

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

LeetCode Support commented: Thank you for reaching out about the issue you're experiencing with the submission of your solution for the problem "567. Permutation in String". Based on the description you provided, it looks like the Time Limit Exceeded error is occurring during the submission process. This typically happens when the solution does not efficiently handle larger or more complex inputs within the specified time constraints.

I suggest reviewing your algorithm to optimize its performance, particularly focusing on reducing the time complexity. Consider leveraging sliding window techniques or other efficient data structures to enhance execution speed.

Please refer to the discussion forums and editorial sections of the problem for hints and solutions from the community, which can be beneficial for refining your approach. If you have any other questions or concerns, don't hesitate to reach out again.

LeetCode Support Team

abdmankhan commented 3 days ago

Then why it is getting accepted in user testcases section. please give me reason for that.

On Sat, 5 Oct, 2024, 11:47 am exalate-issue-sync[bot], < @.***> wrote:

LeetCode Support commented: Thank you for reaching out about the issue you're experiencing with the submission of your solution for the problem "567. Permutation in String". Based on the description you provided, it looks like the Time Limit Exceeded error is occurring during the submission process. This typically happens when the solution does not efficiently handle larger or more complex inputs within the specified time constraints.

I suggest reviewing your algorithm to optimize its performance, particularly focusing on reducing the time complexity. Consider leveraging sliding window techniques or other efficient data structures to enhance execution speed.

Please refer to the discussion forums and editorial sections of the problem for hints and solutions from the community, which can be beneficial for refining your approach. If you have any other questions or concerns, don't hesitate to reach out again.

LeetCode Support Team

— Reply to this email directly, view it on GitHub https://github.com/LeetCode-Feedback/LeetCode-Feedback/issues/24611#issuecomment-2394946582, or unsubscribe https://github.com/notifications/unsubscribe-auth/ASJYDRUF4HUZJXBROBAZXGLZZ577FAVCNFSM6AAAAABPNBWXYKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGOJUHE2DMNJYGI . You are receiving this because you authored the thread.Message ID: @.***>

exalate-issue-sync[bot] commented 2 days 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