LeetCode-Feedback / LeetCode-Feedback

658 stars 313 forks source link

[BUG] - <title> #23097

Closed student-om closed 1 month ago

student-om commented 1 month ago

LeetCode Username

student-om

Problem Number, Title, and Link

  1. Maximum Score From Removing Substrings

Bug Category

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

Bug Description

Time Limit Exceeded 56 / 76 testcases passed Last Executed Input Use Testcase

x = 2890 y = 1643

Language Used for Code

None

Code used for Submit/Run operation

class Solution {
    public int maximumGain(String s, int x, int y) {
        StringBuilder sb = new StringBuilder(s);
       int maxPoints=0;

    if(y>x){
        while(sb.indexOf("ba")!=-1){
        sb.delete( sb.indexOf("ba"), sb.indexOf("ba")+2);
        maxPoints+=y;
        }

        while(sb.indexOf("ab")!=-1){
            sb.delete( sb.indexOf("ab"), sb.indexOf("ab")+2);
            maxPoints+=x;
            }
    }

    else{
        while(sb.indexOf("ab")!=-1){
            sb.delete( sb.indexOf("ab"), sb.indexOf("ab")+2);
            maxPoints+=x;
            }

        while(sb.indexOf("ba")!=-1){
        sb.delete( sb.indexOf("ba"), sb.indexOf("ba")+2);
        maxPoints+=y;
        }

    }
return maxPoints;
    }
}

Expected behavior

n

Screenshots

No response

Additional context

No response

exalate-issue-sync[bot] commented 1 month ago

Winston Tang commented: Hello student-om,

Thank you for your report. However, based on the details provided, it appears that the issue may actually lie in your algorithm's design and performance, rather than a deficiency in LeetCode's problem or test cases.

To handle large inputs within the acceptable time limit, you might need to optimize your code to improve its efficiency. Take into consideration the time complexity of your code, and look into other algorithmic strategies that could enhance its performance, such as using a stack or deque or applying other methods to reduce redundancy in searching operations.

Remember, if you believe there is a missing test case, please provide the specific test case that hasn't been considered and an incorrectly Accepted code.

We hope this helps, and we encourage you to keep trying and learning. If you need further clarification, please feel free to reach out.

LeetCode Support Team

student-om commented 1 month ago

Winston Tang commented: Hello student-om,

Thank you for your report. However, based on the details provided, it appears that the issue may actually lie in your algorithm's design and performance, rather than a deficiency in LeetCode's problem or test cases.

To handle large inputs within the acceptable time limit, you might need to optimize your code to improve its efficiency. Take into consideration the time complexity of your code, and look into other algorithmic strategies that could enhance its performance, such as using a stack or deque or applying other methods to reduce redundancy in searching operations.

Remember, if you believe there is a missing test case, please provide the specific test case that hasn't been considered and an incorrectly Accepted code.

We hope this helps, and we encourage you to keep trying and learning. If you need further clarification, please feel free to reach out.

LeetCode Support Team

ok thank you.