Recent Notes

LeetCode 刷题记录

You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the t...

字符串查找算法 KMP

当我们在查找字符串 str的子串subStr时,大致的想法是设定两个指针i j,分别指向str subStr的头,逐个比较,当字符相同时,++j,当不符合时++i j = 0。直到匹配到str或subStr尾,比较j是否等于subStr.length(),相等则表明匹配成功,且起始索引为i;否则不存在,返回-1。对于特殊的情况,subStr为空的情况下...

整数转罗马数字

``` c++ string intToRoman(int num) { char roman[7] = {‘I’, ‘V’, ‘X’, ‘L’, ‘C’, ‘D’, ‘M’}; std::string result = “”; int base = 0; while (num) { int cu...

N 个圆括号的所有组合情况

建议在看看大家的解答情况,自己写的包含特殊情况总感觉不是很好。

电话号码的字母组合

``` c++ vector letterCombinations(string digits) { int cur = 0;