それぞれが 2 つの可能な値のいずれかになる要素を持つ 2 つのリストがあり、2 つのリストが 1 つの値を除いて同一である場合、その値のインデックスを見つけるにはどの方法を使用すればよいですか? 背景情報として、これを Python でコーディングします。
方法 A:
1. represent both lists as a binary literals
2. use XOR on the two binary literals to give a value "v" that is a power of 2
3. finally, use math.log(v, 2) to get the index
または方法 B:
just iterate through both lists until a different element is found and
get the index
またはPythonを使用した別の方法ですか?