1.题目要求:
2.题目代码:
class Solution {
public:int maximumGap(vector<int>& nums) {if(nums.size() < 2){return 0;}//先进行排序sort(nums.begin(),nums.end());int max = 0;//找到最大间距for(int i = 0;i < nums.size() - 1;i++){if(nums[i + 1] - nums[i] > max){max = nums[i + 1] - nums[i];}}return max;}
};