Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing Test Case - 2981. Find Longest Special Substring That Occurs Thrice I #25821

Closed
karygauss03 opened this issue Dec 10, 2024 · 1 comment

Comments

@karygauss03
Copy link

LeetCode Username

karygauss03

Problem Number, Title, and Link

https://leetcode.com/problems/find-longest-special-substring-that-occurs-thrice-i

Bug Category

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

Bug Description

For this problem, I submitted the attached solution and it was accepted, then I found case when it should fail.
When s = "abcccccdddd", the expected output is 3, but the returned value was 1. You need to add such test to make it stronger!

Language Used for Code

C++

Code used for Submit/Run operation

class Solution {
public:
    int maximumLength(string s) {
        int n = s.size();
        vector<vector<int>> freq(26, vector<int>(3, -1));
        int cur = 0, ans = -1;
        char prev = s[0];
        for (auto &c : s) {
            if (c == prev) {
                ++cur;
            }
            else {
                cur = 1;
                prev = cur;
            }

            auto it = min_element(freq[c - 'a'].begin(), freq[c - 'a'].end());
            if (cur > *it) {
                // cout << "before: " << *it << endl;
                *it = cur;
                // cout << "after: " << *it << endl;
            }
        }

        for (int i = 0; i < 26; ++i) {
            ans = max(ans, *min_element(freq[i].begin(), freq[i].end()));
        }

        return ans;
    }
};

Expected behavior

Expected result 3, but the output was 1!

Screenshots

image

Additional context

No response

Copy link

LeetCode Support commented: Hello,

Thank you for contributing to LeetCode and submitting a missing test case. Upon review, we found that your code indeed failed as expected. This may have resulted from a recent update where similar test cases were integrated into our system, which now accurately detects the issues in your submission.

If you would like to resubmit your code for further review or if you have any additional questions, please feel free to reply to this message or open a new issue with us.

Thank you for your engagement and for helping us improve our platform.

Best regards,
LeetCode Support Team

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant