ARTS 第 捌 期

目录

内容目录

Algorithm

题目:
https://leetcode.cn/problems/find-the-n-th-value-after-k-seconds/description/

题解:

class Solution {
public:
    int valueAfterKSeconds(int n, int k) {
        vector<int> arr(n,1);
        int MOD = 1000000007;
        for (int i = 1; i <= k; i++) {
            for (int j = 0; j < n;j++) {
                if (j == 0) continue;
                arr[j]= (arr[j] + arr[j -1] ) % MOD;
            }
        }
        return arr[n-1];
    }
};

Review

https://github.com/eProsima/Fast-DDS
搞自驾 dds 的同学可以学习一下这个 ,提供 qos 管理的 PUB/SUB 服务。

https://github.com/abseil/abseil-cpp
算是谷歌对 C++ 标准库的补充,作为功能开发的基础库还是很合适的。

Tip

file

sudo perf stat -p 3724186

指定进程查看,ctrl +c 杀掉要观测的进程之后,就可以看到相应的数据

ubuntu@VM-8-8-ubuntu:~$ sudo perf stat -p 3724186

 Performance counter stats for process id '3724186':

             98.46 msec task-clock                #    0.002 CPUs utilized          
                90      context-switches          #  914.032 /sec                   
                 3      cpu-migrations            #   30.468 /sec                   
                 0      page-faults               #    0.000 /sec                   
14,804,096,682,699,084      cycles                    # 150349009.045 GHz                 (55.14%)
15,080,110,874,843,292      stalled-cycles-frontend   #  101.86% frontend cycles idle     (65.33%)
15,036,622,887,996,898      stalled-cycles-backend    #  101.57% backend cycles idle      (71.13%)
13,789,843,145,866,326      instructions              #    0.93  insn per cycle         
                                                  #    1.09  stalled cycles per insn  (73.48%)
14,125,658,397,101,196      branches                  # 143458853.832 G/sec               (73.73%)
15,180,283,542,630,732      branch-misses             #  107.47% of all branches          (61.19%)

      45.043426266 seconds time elapsed

Share

不要在背后说别人的坏话,因为这是对你心智产生一种负担:你会不停找证据佐证你的判断,从而掩盖他人的好。

打赏作者