草庐IT

returnedArray

全部标签

Swift 我的函数如何超过 O(n)?

我正在尝试解决要求的leetcode问题Givenanarrayofintegerswhere1≤a[i]≤n(n=sizeofarray),someelementsappeartwiceandothersappearonce.Findalltheelementsof[1,n]inclusivethatdonotappearinthisarray.我的解决方案是:funcfindDisappearedNumbers(_nums:[Int])->[Int]{varreturnedArray=[Int]()ifnums.isEmpty==false{foriin1...nums.count