PRPALN - Editorial

Please check this solution, I seem to be using the same algorithm as described by you. If you can give me some or one of the test cases where my code fails, that would be highly appreciated.
http://www.codechef.com/viewsolution/5336073
Thank you.

1 Like

@thegreatheisenberg Here’s a test case for which your code gives incorrect answer…
ololllollo
Answer should be YES… yours giving NO

3 Likes

I would say, if you code prints YES for inputs:

X010
0X10
01X0
010X
X0110
0X110
01X10
011X0
0110X

and NO for inputs:

YX010
XY010
X0Y10
X01Y0
X010Y
Y0X10
0YX10
0XY10
0X1Y0
0X10Y
Y01X0
0Y1X0
01YX0
01XY0
01X0Y
Y010X
0Y10X
01Y0X
010YX
010XY

It should be ok , generated with - 3N7D2h - Online Java Compiler & Debugging Tool - Ideone.com .

I know that in input only ‘a’…‘z’ should be, but it shouldn’t matter for correct algorithm.

Please help me, why this code is not passing for all test case?-code link link

1 Like

Amongst the test cases uploaded by betlista, I think there are two in-accuracies. X01Y10 can be converted to a palindrome by deleting exactly one character - X.

Similarly Y01X10 can be converted to a palindrome by deleting Y.

Am I missing out something here?

2 Likes

are the problems added to practice sections?

1 Like

This problem can be solved in O(n) time.

You scan the string from left to right, right to left, middle to left, middle to right.

The main idea, is that you have S[i]=S[L-1-i] or S[L-2-i] if you remove an element on the right.

See code here: CodeChef: Practical coding for everyone

1 Like

Here is my solution:
http://www.codechef.com/viewsolution/5292391

I am still not able to figure out a case where it is failing.
All test cases mentioned by @betlista is passing.

1 Like

PRPALN is not available anywhere in practice section. Please fix it. Provide the link if iam wrong.

I have followed exactly the same algorithm but it is still failing for some test cases. Please somebody clarify and douse my curiosity. Here is my solution: CodeChef: Practical coding for everyone

is the problem there in the practice section ?

my code is giving correct answers for all testcases yet I am getting a wrong answer when submitting plzzz help

here is the link to my code
http://ideone.com/5F4fPP

My Code passes all the test cases in the forumn but still getting W.A. please help SVIsBv - Online C Compiler & Debugging Tool - Ideone.com

please check i always find wrong answer in this ques i added the link of my code.

http://www.codechef.com/viewsolution/6782245

https://www.codechef.com/viewsolution/16729475
Please can a test case where my code fails. I have implemented the same algorithm.

I tried your code with all test cases I wrote above - AqSH1H - Online C++ Compiler & Debugging Tool - Ideone.com

One of failing ones is: YES for X01Y10

yes, they have been added to the practice section. This must be in the easy sub-section.

You are correct, my bad, I have to edit the post…

for

1
X0Y10

your code returns YES

I added links :wink: