我试图找出两个字符串是否是字谜,而这段代码验证了它们的长度是否相等。怎么样?
答案 0 :(得分:0)
str1是一个(字符)数组。 str2是一个(字符)数组。
此代码检查是否:
索引i
存在于str1
上
-OR-
索引i
存在于str2
如果您的两个数组是
['a', 'b', 'c']
['w', 'x', 'y', 'z']
它可能会首先检查索引0
i=0 // 'a' exists
i=1 // 'b' exists
i=3 // 'c' exists
i=4 // 'z' exists - first didn't match, so checks second
i=5 // doesn't exist
i=6 // doesn't exist
i=7 // doesn't...