PRPALN - Editorial

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:

I added links :wink:

I added links :wink:

Hiding exception is very very bad practice!

Try

1
ac