LeetCode-Feedback / LeetCode-Feedback

667 stars 324 forks source link

Missing Test Case - 1405. Longest Happy String #24799

Open sreecharan1306 opened 23 hours ago

sreecharan1306 commented 23 hours ago

LeetCode Username

mscharan1313

Problem Number, Title, and Link

  1. Longest Happy String https://leetcode.com/problems/longest-happy-string/

Bug Category

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

Bug Description

Test case a=3, b=0, c=4 works and was accepted. However, test case a=3, b=4, c=0 does not work with my code.

Language Used for Code

Python/Python3

Code used for Submit/Run operation

class Solution:
    def longestDiverseString(self, a: int, b: int, c: int) -> str:
        p=dict()
        p['a']=a
        p['b']=b
        p['c']=c
        s=""
        la=''
        while True:
            if p['c']>= max(p['a'],p['b']):
                if la!='c':
                    if p['c']>=2:
                        s+='cc'
                        la='c'
                        p['c']-=2
                    else:
                        s+='c'
                        la='c'
                        p['c']-=1
                if p['a']==0 and p['b']==0:
                    return s
                else:
                    if p['a']>p['b']:
                        if p['a']>=2:
                            s+='aa'
                            la='a'
                            p['a']-=2
                        else:
                            s+='a'
                            la='a'
                            p['a']-=1
                    else:
                        s+='b'
                        la='b'
                        p['b']-=1
                if p['a']==0 and p['b']==0 and p['c']==0:
                    return s
                print(p)
                print(s+'1')
                print(la)
            elif p['b']>=max(p['a'],p['c']):
                if la!='b':
                    if p['b']>= 2:
                        s+='bb'
                        la='b'
                        p['b']-=2
                    else:
                        s+='b'
                        la='b'
                        p['b']-=1
                if p['a']==0 and p['c']==0:
                    return s
                else:
                    if p['a']>p['c']:
                        s+='a'
                        la='a'
                        p['a']-=1
                    else:
                        s+='c'
                        la='c'
                        p['c']-=1
                if p['a']==0 and p['b']==0 and p['c']==0:
                    return s
                print(p)
                print(s+'2')
                print(la)
            elif p['a']>=max(p['b'],p['c']):
                if la!='a':
                    if p['a']>=2:
                        s+='aa'
                        la='a'
                        p['a']-=2
                    else:
                        s+='a'
                        la='a'
                        p['a']-=1
                if p['c']==0 and p['b']==0:
                    return s
                else:
                    if p['c']>p['b']:
                        s+='c'
                        la='c'
                        p['c']-=1
                    else:
                        s+='b'
                        la='b'
                        p['b']-=1
                if p['a']==0 and p['b']==0 and p['c']==0:
                    return s
                print(p)
                print(s+'3')
                print(la)
            # print(p)
        return s

Expected behavior

In the first test case where a=3, b=0, and c=4, the code appears to function correctly and produces the expected result, leading to an "accepted" status. This indicates that the logic implemented in the code is correctly handling this specific set of input values.

In the second test case with a=3, b=4, and c=0, the code does not work as intended, meaning it fails to produce the correct output based on the expected logic. However, it still receives an "accepted" status, which suggests that the test case did not adequately capture the edge cases where the code failed.

The expected behavior is that the code should function correctly for all given test cases to be deemed as "accepted." However, the discrepancy lies in the fact that it was accepted despite a failure to provide the correct output in the second case. This inconsistency may indicate issues in lack of edges cases in test cases.

Screenshots

No response

Additional context

No response

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