Need explanation for input "abcda"!!


  • 1
    A

    Why input "abcda" should return "a"?
    Doesn't make sense at all!

    Can anyone explain?


  • 0
    S

    First of all, 'b' and 'd' are different, so the longest palindromic substring is of length 1. Then it comes down to the question of which version of the substring to choose. If it returns "a", it means the algorithm choose the first longest substring.


  • 1
    A

    @solosodium Thanks for the reply. I understand what you said. But do you agree that this is an wrong input? It was described in the question that there only exist one unique right answer. I'm a picky person, never mind~ Thanks anyway!


  • 0
    S

    I have the same query. in "abcda", 'b' and 'd' are as valid as 'a' and the question doesn't ask for the first longest substring. Anyone knows how to ask the Admin about this?


  • 0

    I have the same problem. got this as wrong input. Maybe the question is wrong...
    Input:
    "abcda"
    Output:
    "b"
    Expected:
    "a"


  • 0

    Thanks for raising this. This is just fixed. Also updated the problem description.


  • 0
    C

    @1337c0d3r could you please explain in what scenes the issue was fixed. The test case still expects "a" for the string "abcda" in my opinion there is no palindromic sub-string at all in this input.


  • 0

    @Cepera Previously, the judge will only accept "a" for the input "abcda". But "b", "c", or "d" are also valid answers. So the judge should accept any of them as correct answer. Your code returns "" for this input, so it is judged as Wrong Answer.


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.