淘客熙熙

主题:求教大家一个算法问题 -- looklook

共:💬24 🌺10
全看分页树展 · 主题 跟帖
家园 not the most efficient method

you sure this is the solution for msft interview question?

if the sequence is continuous (but one missing/duplicating) and bounded, the solution is to take the summation and then get the one missing/duplicating by comparing with the summation of the whole continuous sequence. (actually, i guess one more function, e.g. summation of squres is needed to find the duplicating/missing couple).

全看分页树展 · 主题 跟帖


有趣有益,互惠互利;开阔视野,博采众长。
虚拟的网络,真实的人。天南地北客,相逢皆朋友

Copyright © cchere 西西河