LeetCode 刷题记录
Apr 02, 2022You 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...
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...
当我们在查找字符串 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...