Please help me with this code

https://www.codechef.com/viewsolution/35395634

Please can anyone help me out with this code?I am unable to detect the error.

I don’t really know JAVA so can’t debug the code or anything bud here’s my code

PYTHON CODE:

#t=int(input())
for _ in range(int(input())):
    s=input()
    l=len(s)
    h=l//2
    x=s[:h]
    y=s[(h+l%2):]
    if sorted(x)==sorted(y):
        print("YES\n")
    else:
        print("NO\n")

see if you can translate this and find the mistake

Ya thanks a lot,I can understand the code.This is another approach for this program,but actually I wanted to know the flaw in my code.

consider line 42 :
if(lch[(int)left.charAt(z)-‘a’]==rch[(int)right.charAt(z)-‘a’])

if left is “abb” and right is “bba”
you are comparing freq of ‘a’ with freq of ‘b’
which is wrong.

1 Like

Ya,it executed.Thanks a lot!!