Help me find the answer (ENCMSG)

Here are the problems link
Here is my solution link
My sample test case answer is coming right but when I submit the solution the answer is coming wrong. Please run some test cases on my solution and check the answer, help me if something is wrong with mine code.

I can’t see any constraints stopping the length of the string being 1, which your program can’t handle.

line 23 :
if(j == str.length()-1 && str.length()/2 != 0)
I think it should be str.length()%2 != 0 not str.length()/2 != 0

1 Like