I tried case
"RRWWRRBBRR", "WB". The test program gave the expected answer
-1. However, I thought the answer might be
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?
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.
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.
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.
@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.
@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.
My code yields output 2, too...
It seems the test program has problem and some more test cases need to be added as well.
@1337c0d3r Should we consider putting this question on hold?
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.