mirror of
				https://git.wolves.top/wolves/leetcode.git
				synced 2025-11-04 17:26:32 +08:00 
			
		
		
		
	init
This commit is contained in:
		
							
								
								
									
										22
									
								
								24/09/2860.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								24/09/2860.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,22 @@
 | 
			
		||||
#include <vector>
 | 
			
		||||
 | 
			
		||||
using namespace std;
 | 
			
		||||
 | 
			
		||||
int countWays(vector<int> &nums) {
 | 
			
		||||
    sort(nums.begin(), nums.end());
 | 
			
		||||
    int count = 0;
 | 
			
		||||
    for (int i = 0; i <= nums.size(); i++) {
 | 
			
		||||
        if (i == 0) {
 | 
			
		||||
            if (nums[0] != 0) {
 | 
			
		||||
                count++;
 | 
			
		||||
            }
 | 
			
		||||
            continue;
 | 
			
		||||
        }
 | 
			
		||||
        if (i == nums.size() && i > nums[nums.size()]) {
 | 
			
		||||
            count++;
 | 
			
		||||
            continue;
 | 
			
		||||
        }
 | 
			
		||||
        if (i > nums[i - 1] && i < nums[i])count++;
 | 
			
		||||
    }
 | 
			
		||||
    return count;
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user