《计算几何》听课小笔记>

xiaoxiao2021-02-27  758

1)1-1000放在含有1001个元素的正整数数组中,只有唯一的一个元素值重复,其它均只出现一次。下列哪种算法查找这个重复元素最快?

方法:XOR all the numbers in the array together, then XOR number from 1 to 1000 (现将数组中所有数异或在一起,再与1-1000各异或一次)

转载请注明原文地址: https://www.6miu.com/read-571.html

最新回复(0)