ARTS 第 壹 期

目录

Algorithm

题目:
https://leetcode.cn/problems/count-the-number-of-special-characters-i/description/

题解:
最直观的想法是枚举 26 个字母 c,遍历 word 中的字母,判断是否同时存在大小写,如果是则总数加一,时间复杂度为 O(N^2)

class Solution {
public:
    int numberOfSpecialChars(string word) {
        int num = 0;
        for (char c = 'a'; c <= 'z'; c++) {
            bool is_lower_flag = false, is_upper_flag = false;
            for (char letter : word) {
                if (c == letter ) {
                    is_lower_flag = true;
                }
                if (c - 32 == letter) {
                    is_upper_flag = true;
                }
            }
            if (is_lower_flag && is_upper_flag) {
                num++;
            }
        }
        return num;
    }
};

Review

[https://www.khronos.org/assets/uploads/developers/presentations/02_OpenVX-Introduction_May17a.pdf]()
openvx 入门简介

Tip

使用 clang format 来格式化代码(使用谷歌 C++规范):

clang-format style=Google -i  a.cpp

Google C++ 规范

Autosar C++14 指南
https://www.autosar.org/fileadmin/standards/R22-11/AP/AUTOSAR_RS_CPP14Guidelines.pdf

Share

使用 C++ 动态追踪 C++ 应用


非侵入式动态追踪技术(Dtrace),值得深究

打赏作者