Back to course home
0% completed
Vote For New Content
Easy Solution - CPP - Since array modification is allowed
chillaxspotify
Feb 20, 2025
class Solution { public: int findDuplicate(vector<int>& nums) { for(auto i = 0; i < nums.size(); ++i) { auto mark = abs(nums[i]) - 1; if (nums[mark] > 0 ) nums[mark] *= -1; else return abs(nums[i]); } return -1; } };
0
0
Comments
Comments
On this page