LeetCode #1426

LeetCode #1426

1개의 풀이 · C++

문제 원문 보기 ↗

SOLUTION INFO

C++ · main.cpp

main.cpp
class Solution {
public:
    int countElements(vector<int>& arr) {
        ios::sync_with_stdio(false);cin.tie(0);
        int count[1001] = {0};
        for(auto &i : arr)
            count[i]++;
        int ans = 0;
        for(int i=1;i<=1000;i++){
            if(count[i - 1] == 0 || count[i] == 0)continue;
            ans += count[i-1];
        }
        return ans;
    }
};

SOLUTION DESCRIPTION

풀이 설명

등록된 풀이 설명이 없습니다.