LeetCode:10.正则表达式匹配
给你一个字符串 s 和一个字符规律 p,请你来实现一个支持 ‘.’ 和 ’‘ 的正则表达式匹配。
‘.’ 匹配任意单个字符
‘’ 匹配零个或多个前面的那一个元素
所谓匹配,是要涵盖 整个 字符串 s的,而不是部分字符串。
示例 1:
输入:s = “aa” p = “a”
输出:false
解释:”a” 无法匹配 “aa” 整个字符串。
示例 2:
输入:s = “aa” p = “a”
输出:true
解释:因为 ‘’ 代表可以匹配零个或多个前面的那一个元素, 在这里前面的元素就是 ‘a’。因此,字符串 “aa” 可被视为 ‘a’ 重复了一次。
示例 3:
输入:s = “ab” p = “.”
输出:true
解释:”.” 表示可匹配...
ParallelStream 的正确打开方式
ParallelStream 是什么
ParallelStream 其实就是一个并行执行的流.它通过默认的ForkJoinPool,1可能提高你的多线程任务的速度.
Fork/Join ↩
KMP 字符串匹配
1
2
3
4
5
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
void preKmp(char *x, int m, int kmpNext[]) {
int i, j;
i = 0;
j = kmpNext[0] = -1;
while (i < m) {
while (j > -1 && x[i] != x[j])
j = kmpNext[j];
i++;
j++;
if (x[i] == x[...
Bye Bye NPE
This led me to suggest that the NULL value is a member of every type, and a NULL check is required on every use of that reference variable, and it may be perhaps a billion dollar mistake. 1
– Tony Hoare
What’s wrong with NULL
Simply put, NULL reference (or NULL pointer) is a special marker and keyword indicating that something has no value.Pr...