目录
内容目录
						
						Algorithm
题解:
方法一:
时间复杂度:O(N*N)
class Solution {
public:
    int countCompleteDayPairs(vector<int>& hours) {
        int ans = 0;
        for(int i = 0; i < hours.size();i++) {
            for (int j = i + 1; j < hours.size(); j++)
                if ((hours[i] + hours[j]) % 24 == 0) {
                    ans++;
                    continue;
                    i = j+1;
                }
        }
        return ans;
    }
};
方法二:
时间复杂度:O(N)
class Solution {
public:
    long long countCompleteDayPairs(vector<int>& hours) {
        long long ans = 0;
        long long cnt[24] = {};
        for (auto it : hours) {
            ans += cnt[(24 - it % 24) % 24];
            cnt[it % 24] ++;
        }
        return ans;
    }
};Review
https://microsoft.github.io/mimalloc/bench.html
微软出品的内存分配管理器,performance 比 jemalloc, tcmalloc, Hoard 都厉害,最差情况下内存节省 25% 左右。
Tip
bazel 生成静态库,可以通过在 cc_library 中 加参数 “linkstatic = true” 来控制
审视自己应该从18岁时的视角,他人的评价仅供参考,自信也不应该建立在他人的评价之上。
打赏作者
