if i need to check if the array is anagram or if both array are anagram i just but each letter in a first array in hash with key that is the number of how much it in the index and check from the other array if the first index in the hash..
her i do'nt know from where to start cuz there is no hash map her so it make the solution difficult!
in my julia solution
this is the final code
any one know how to convert it to lua ..
her i do'nt know from where to start cuz there is no hash map her so it make the solution difficult!
in my julia solution
this is the final code
Lua:
function anagrams(a,b)
res = zeros(Int,length(a))
for i=1:length(a)
a1 = sort(collect(a))
b1 = sort(collect(b))
for j=1:min(length(a1),length(b1))
if length(a1) <= length(b1)
if a1[j] in b1
res +=1
j +=1
else
j+=1
end
else
if b1[j] in a1
res +=1
j +=1
else
j+=1
end
end
end
end
return res
end
a = ["teewaa" , "ategh" , "simplefo"]
b = ["atwe" , "atcgh" , "fore"]
println(anagrams(a,b))
any one know how to convert it to lua ..