LeetCode-Feedback / LeetCode-Feedback

661 stars 315 forks source link

Test case bug 208 & 211 #20199

Closed nuenuehao2 closed 7 months ago

nuenuehao2 commented 7 months ago

LeetCode Username

nuenuehao2

Problem number, title, and link

208: https://leetcode.com/problems/implement-trie-prefix-tree/?source=submission-noac 211: https://leetcode.com/problems/design-add-and-search-words-data-structure/description/

Category of the bug

Description of the bug

Wrong results for the below test case ["Trie","startsWith"] [[],["a"]]

Language used for code

Python3

Code used for Submit/Run operation

class TreeNode:
    def __init__(self, references=[None for _ in range(26)], isEnd=False):
        self.references = references
        self.isEnd = isEnd

class Trie:

    def __init__(self):
        self.root = TreeNode()

    def insert(self, word: str) -> None:
        curr = self.root
        for c in word:
            curr.references[ord(c) - ord('a')] = TreeNode()
            curr = curr.references[ord(c) - ord('a')]
        curr.isEnd = True

    def search(self, word: str) -> bool:
        curr = self.root
        for c in word:
            if curr.references[ord(c) - ord('a')]:
                curr = curr.references[ord(c) - ord('a')]
            else: 
                return False
        if curr.isEnd:
            return True
        else:
            return False

    def startsWith(self, prefix: str) -> bool:
        curr = self.root
        for c in prefix:
            if curr.references[ord(c) - ord('a')]:
                curr = curr.references[ord(c) - ord('a')]
            else:
                return False
        return True

Expected behavior

Accepted

Screenshots

image image

Additional context

LC-Pam commented 7 months ago

Dear user,

Thank you for submitting your code to our platform. After a thorough evaluation, we regret to inform you that your code did not produce the expected results. Our code judge is functioning correctly, and we have verified the correctness of our evaluation process.

We kindly suggest that you review your code carefully and ensure it adheres to the problem requirements and constraints. It may be beneficial to double-check your logic, algorithm implementation, and any potential errors or corner cases that could affect the code's performance.

Additionally, we encourage you to explore our discussion board, where you can seek assistance from the community. Many experienced users and experts are available to help troubleshoot issues, provide insights, and offer guidance on improving your code.

We believe that by reviewing your code and actively engaging with the community, you will have a better chance of identifying and resolving the discrepancies. Remember, learning from such experiences and iterating on your code is an essential part of the programming journey.

We appreciate your understanding and encourage you to continue learning and improving your coding skills.

Should you have any further questions or need additional support, please don't hesitate to reach out to us.

Best regards,

The LeetCode Team

nuenuehao2 commented 7 months ago

Thanks for the reply! May I know why the test case is accepted, but the submission is wrong answer for the same test case? And why the output is different for the same test case?

image

On Thu, Feb 8, 2024 at 11:28 AM LC_M @.***> wrote:

Dear user,

Thank you for submitting your code to our platform. After a thorough evaluation, we regret to inform you that your code did not produce the expected results. Our code judge is functioning correctly, and we have verified the correctness of our evaluation process.

We kindly suggest that you review your code carefully and ensure it adheres to the problem requirements and constraints. It may be beneficial to double-check your logic, algorithm implementation, and any potential errors or corner cases that could affect the code's performance.

Additionally, we encourage you to explore our discussion board, where you can seek assistance from the community. Many experienced users and experts are available to help troubleshoot issues, provide insights, and offer guidance on improving your code.

We believe that by reviewing your code and actively engaging with the community, you will have a better chance of identifying and resolving the discrepancies. Remember, learning from such experiences and iterating on your code is an essential part of the programming journey.

We appreciate your understanding and encourage you to continue learning and improving your coding skills.

Should you have any further questions or need additional support, please don't hesitate to reach out to us.

Best regards,

The LeetCode Team

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