import math class Solution(object): def findDuplicate(self, nums): """ :type nums: List[int] :rtype: int """ for num in nums: if nums[abs(num)] < 0: return abs(num) else: nums[abs(num)] *= -1
@HenryGau Probably because the very first note clearly says "You must not modify the array" (emphasis not mine). So this is obviously not an ok solution.
@StefanPochmann thanks, I missed that condition :)
Because you can not change the array
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.