Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution {
- public:
- int missingNumber(vector<int>& nums) {
- sort(nums.begin(), nums.end());
- int n = nums.size();
- for (int i = 0; i < n - 1; i++)
- {
- int razlika = nums[i + 1] - nums[i];
- if(razlika == 2)
- {
- return nums[i + 1] - 1;
- }
- }
- if(nums[0] != 0) {
- return 0;
- }
- else {
- return nums[n - 1] + 1;
- }
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement