草庐IT

firstDuplicate

全部标签

javascript - 为 codefighters javascript firstDuplicate() 函数加速此代码

来自Codefighters:Note:WriteasolutionwithO(n)timecomplexityandO(1)additionalspacecomplexity,sincethisiswhatyouwouldbeaskedtododuringarealinterview.Givenanarrayathatcontainsonlynumbersintherangefrom1toa.length,findthefirstduplicatenumberforwhichthesecondoccurrencehastheminimalindex.Inotherwords,ifth