https://www.codechef.com/viewsolution/39229101
above is link for the solution of Lapindrome string in DSA Learning Series.
I tested it with the testcases provided in the problem statement and it works perfect.
But on submitting it shows wrong solution.
Please tell me if i am missing some extreme testcase or any corrections to be made.
let’s take an example
“aaabaaa”
df would be {a:3}
ds would be {a:3}
for kf,vf in df. items(): for ks,vs in ds.items(): if kf == ks and vf == vs: count = count + 1 break
In the first for loop count would become 1 (since (a,3)==(a,3))
There would be no second for loop
so count is 1
if count == len(i)//2: print("YES") else: print("NO")
len(i) is 7
len(i)//2 is 3
count!=len(i)//2
even though “aaabaaa” is a lapindrome
If you want to compare if two dictionaries are equal ,just do
if d1==d2:
print(“YES”)
else:
print(“NO”)