My submission works when I provide the sample test case as custom input, but on submission I get “Wrong Solution”. Could somebody help me in understanding the test cases that my program might be failing?
Consider the test input:
(on my machine, it gives the answer
Yes you’re right. I think while converting the array back into string, I needed to set the condition as (n+1) instead of n, as the arrays were empty when executing your test case. Thank you so much!
The first thing I notice when I see your code is that it is too long for this problem or maybe it is because of C++ language(I code in Python) and BTW I don’t understand your code because I have no clue about C++.
Try my approach(It is really straightforward):
take the input
if the length is odd then delete middle character because we got nothing to do with it.
slice the string into two different ones from b/w.
if they are equal means answer is yes else answer is no.
I don’t know if there are in built functions in C++ to sort strings and list but it must be there I guess.
My code is in Python but Python is quite easy to read and understand so take a look at my code here:
I hope this helps you