Advertisement
Josif_tepe

Untitled

Jan 20th, 2023
741
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.40 KB | None | 0 0
  1. class Solution {
  2. public:
  3.     bool containsDuplicate(vector<int>& nums) {
  4.          
  5.         sort(nums.begin(), nums.end());
  6.         int n = nums.size();
  7.         for (int i = 0; i < n - 1; i++)
  8.         {
  9.             int razlika = nums[i + 1] - nums[i];
  10.             if(razlika == 0)
  11.             {
  12.                 return true;
  13.             }
  14.            
  15.         }
  16.         return false;
  17.     }
  18. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement