Contents

ARST打卡第203周[203/521]

Algorithm

lc2395_和相等的子数组

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
class Solution {
public:
    // 用一个集合维护所有的相邻和即可
    bool findSubarrays(vector<int>& nums) {
        // set<int> two_sum;
        // 默认set是红黑树,插入查找都是O(logn),hash_set都是O(1)
        // 这个题测试用例 set 时间更快
        // 可能是用hash_set,插入有hash碰撞,或者时间常数较大
        unordered_set<int> two_sum;
        for (int i = 1; i < nums.size(); i++) {
            int tmp = nums[i-1] + nums[i];
            if (two_sum.find(tmp) != two_sum.end()) {
                return true;
            }
            two_sum.insert(tmp);
        }
        return false;
    }
};

Review

Scaling Raft

This is where MultiRaft comes in: instead of allowing each range to run Raft independently, we manage an entire node’s worth of ranges as a group. Each pair of nodes only needs to exchange heartbeats once per tick, no matter how many ranges they have in common.

这是一个好方法,把大量的通信转降低成节点间的通信,还有一种方法就是是braft的静默模式,暂时将主动Leader Election的功能关闭,这样就不需要维护Leader Lease的心跳了,依靠业务Master进行被动触发Leader Election,这个可以只在Leader节点宕机时触发,整体的心跳数就从复制实例数降为节点数

Tips

B+树,B-link树,LSM树…一个视频带你了解常用存储引擎数据结构

Share-关于markdown-preview-enhanced字体设置

安装hack字体

然后按照这个官网链接操作 + Google看别人之前的实践

一开始操作失误,填成了这样

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/* Please visit the URL below for more information: */
/*   https://shd101wyy.github.io/markdown-preview-enhanced/#/customize-css */

.markdown-preview.markdown-preview {
  // modify your style here
  // eg: background-color: blue;
  @font-face {
    font-family: "Hack";
    src: url("C:\\Windows\\Fonts\\Hack");
  }
  
  // 这里和父标题一样,搞错了...
  .markdown-preview.markdown-preview {
    font-family: "Hack" sans-serif;
  
    h1,
    h2,
    h3,
    h4,
    h5,
    h6,
    pre,
    code {
      font-family: "Hack" sans-serif;
    }
  }
}

后面改成这样就成功了

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20

/* Please visit the URL below for more information: */
/*   https://shd101wyy.github.io/markdown-preview-enhanced/#/customize-css */

.markdown-preview.markdown-preview {
  // modify your style here
  // eg: background-color: blue;
  font-family: Hack;

  h1,
  h2,
  h3,
  h4,
  h5,
  h6,
  pre,
  code {
    font-family: Hack;
  }
}

linux安装hack字体

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
## 下载安装Hack字体
mkdir ~/download
cd ~/download
 ⚡ 03/20|11:25:14  download  wget https://github.com/source-foundry/Hack/releases/download/v3.003/Hack-v3.003-ttf.zip

--2023-03-20 11:25:23--  https://github.com/source-foundry/Hack/releases/download/v3.003/Hack-v3.003-ttf.zip
Resolving github.com (github.com)... 20.205.243.166
Connecting to github.com (github.com)|20.205.243.166|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://objects.githubusercontent.com/github-production-release-asset-2e65be/37829238/2cfb7c46-20ba-11e8-8018-6b655abec399?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20230320%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20230320T032523Z&X-Amz-Expires=300&X-Amz-Signature=fd8b22bbc8f1e73403fa00d5928f6f74bb2206b9d5cbe9b9bd943b4c46cfb78b&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=37829238&response-content-disposition=attachment%3B%20filename%3DHack-v3.003-ttf.zip&response-content-type=application%2Foctet-stream [following]
--2023-03-20 11:25:23--  https://objects.githubusercontent.com/github-production-release-asset-2e65be/37829238/2cfb7c46-20ba-11e8-8018-6b655abec399?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20230320%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20230320T032523Z&X-Amz-Expires=300&X-Amz-Signature=fd8b22bbc8f1e73403fa00d5928f6f74bb2206b9d5cbe9b9bd943b4c46cfb78b&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=37829238&response-content-disposition=attachment%3B%20filename%3DHack-v3.003-ttf.zip&response-content-type=application%2Foctet-stream
Resolving objects.githubusercontent.com (objects.githubusercontent.com)... 185.199.110.133, 185.199.111.133, 185.199.108.133, ...
Connecting to objects.githubusercontent.com (objects.githubusercontent.com)|185.199.110.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 615776 (601K) [application/octet-stream]
Saving to: ‘Hack-v3.003-ttf.zip’

Hack-v3.003-ttf.zip           100%[=================================================>] 601.34K  1.41MB/s    in 0.4s

2023-03-20 11:25:24 (1.41 MB/s) - ‘Hack-v3.003-ttf.zip’ saved [615776/615776]

 ⚡ 03/20|11:25:24  download  ls
Hack-v3.003-ttf.zip
 ⚡ 03/20|11:25:26  download  unzip Hack-v*.zip
Archive:  Hack-v3.003-ttf.zip
   creating: ttf/
  inflating: ttf/Hack-Bold.ttf
  inflating: ttf/Hack-BoldItalic.ttf
  inflating: ttf/Hack-Italic.ttf
  inflating: ttf/Hack-Regular.ttf
 ⚡ 03/20|11:25:54  download  ls
Hack-v3.003-ttf.zip  ttf
 ⚡ 03/20|11:25:57  download  mv ttf Hack
 ⚡ 03/20|11:26:54  download  ls
Hack  Hack-v3.003-ttf.zip
 ⚡ 03/20|11:26:56  download  cp -r Hack /usr/share/fonts
 ⚡ 03/20|11:27:12  download  ls /usr/share/fonts
Hack  truetype

## 设置Hack配置
 ⚡ 03/20|11:31:04  download  wget https://raw.githubusercontent.com/source-foundry/Hack/master/config/fontconfig/45-Hack.conf
--2023-03-20 11:31:16--  https://raw.githubusercontent.com/source-foundry/Hack/master/config/fontconfig/45-Hack.conf
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 185.199.111.133, 185.199.108.133, 185.199.109.133, ...
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|185.199.111.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 537 [text/plain]
Saving to: ‘45-Hack.conf’

45-Hack.conf                  100%[=================================================>]     537  --.-KB/s    in 0s

2023-03-20 11:31:16 (9.64 MB/s) - ‘45-Hack.conf’ saved [537/537]

 ⚡ 03/20|11:31:16  download  cp 45-Hack.conf /etc/fonts/conf.d
 ⚡ 03/20|11:31:36  download  fc-cache -f -v
/usr/share/fonts: caching, new cache contents: 0 fonts, 2 dirs
/usr/share/fonts/Hack: caching, new cache contents: 4 fonts, 0 dirs
/usr/share/fonts/truetype: caching, new cache contents: 0 fonts, 2 dirs
/usr/share/fonts/truetype/dejavu: caching, new cache contents: 22 fonts, 0 dirs
/usr/share/fonts/truetype/liberation: caching, new cache contents: 16 fonts, 0 dirs
/usr/local/share/fonts: caching, new cache contents: 0 fonts, 0 dirs
/root/.local/share/fonts: skipping, no such directory
/root/.fonts: skipping, no such directory
/var/cache/fontconfig: cleaning cache directory
/root/.cache/fontconfig: not cleaning non-existent cache directory
/root/.fontconfig: not cleaning non-existent cache directory
fc-cache: succeeded
 ⚡ 03/20|11:32:41  download  fc-list | grep "Hack"
/usr/share/fonts/Hack/Hack-Regular.ttf: Hack:style=Regular
/usr/share/fonts/Hack/Hack-Italic.ttf: Hack:style=Italic
/usr/share/fonts/Hack/Hack-Bold.ttf: Hack:style=Bold
/usr/share/fonts/Hack/Hack-BoldItalic.ttf: Hack:style=Bold Italic