Challenges • Asked almost 4 years ago by grvchik
I do not understand the explanation of this problem
nums[nums[i] - 1] != nums[i]) can give ArrayIndexOutOfBounds Exception as we are assuming that nums[i] will be an index
Besides this, explanation states we are comparing the current number with previous number
It should be nums[i-1]!=nums[i]
Hi grvchik,
I'm sorry that you're having difficulty with this problem.
nums[i] > 0
clause ensures we don't get an ArrayIndexOutOfBounds
exception.I've gone ahead and recorded an explainer video for it here and updated the tutorial to make it more understandable. Hope it clarifies your issues.