Standard test program is wrong?


  • 39
    H

    Hi all,

    I tried case "RRWWRRBBRR", "WB". The test program gave the expected answer -1. However, I thought the answer might be 2. Because:

    RRWWRRBBRR -> RRWWRRBBR[W]R -> RRWWRRBB[B]RWR -> RRWWRRRWR -> RRWWWR -> RRR -> empty

    The possible reason might be the first [W] was inserted but not adjacent to a W in the sequence. I read the description twice but didn't find any condition about it.

    Could someone give me some ideas about it?


  • 0
    M

    agree with you~
    due to this kind of condition, the sequence of inserting is influential to the result and it's meaningful to insert one color between two same color balls. So it takes more time to right a really "correct" program than the standard test program.


  • 0

    Hi @herbix,

    Thanks for submitting such good test cases, to be honest, the original solution hasn't considered this situation.

    Truly sorry for that, we'll fix this problem as soon as possible.

    If it has been solved, we'll let you know in the first time.

    Best,
    Leetcode Team.


  • 0
    Z

    Hi,
    Your test case is really good! I have seen many submitted answers and all of them choose their searching path intutively without necessary logic proof. My program using DFS to search all the solution space with strict pruning cannot satisfy the time limit. However, many submitted answers choose to detect only a small part of solution space but they can pass the online test! I don't believe they are right although I cannot figure out why they can ignore other possible solutions. Your case offers me a good example to beat them.
    Could you offer me your program which can pass both this test case and online test? Thx.


  • 0
    Z

    @love_FDU_llp I am wondering whether those submitted answers need to be tested again since many of them cannot provide correct result in this case. It feels bad to get a wrong answer when you want to get help from others.


  • 0
    H

    @zx731 Sorry about that I didn't write a program that can pass the both cases. It is passed with the "unproved" algorithm.
    I tried DFS with pruning but time limit exceeded. Maybe time limit shouldn't be so strict if this test case is considered.


  • 0
    W

    @herbix said in Standard test program is wrong?:

    "RRWWRRBBRR", "WB"

    My code yields output 2, too...
    It seems the test program has problem and some more test cases need to be added as well.

    @administrators


  • 0

    @1337c0d3r Should we consider putting this question on hold?


  • 0
    S

    Nice test case! For this question, can we either relax restriction on time complexity or add one more restriction on the description: "Ball only can be inserted beside a ball with same color"?
    @love_FDU_llp


Log in to reply
 

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