如果我有两个列表,每个列表的元素可以是两个可能值之一,并且两个列表除了一个值之外是相同的,我应该使用哪种方法来查找该值的索引?我将在 Python 中将其编码为背景信息
方法一:
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的另一种方式?