
Leetcode
记录Leetcode刷题笔记
从一而终
这个作者很懒,什么都没留下…
展开
-
leetcode647. 回文子串
#include <string>#include <iostream>class Solution {public: int countSubstrings(std::string s) { int ret = 0; if (s.empty() || s.length() <= 0) { return ret; } for (int i = 0;.原创 2021-08-29 08:42:18 · 65 阅读 · 0 评论 -
leetcode9. 回文数
#include <iostream>#include <string>#define _DEBUGclass Solution {public: bool isPalindrome(int x) { std::string strX = int2Str(x); return strIsPalindrome(strX); } // 整数转字符转 std::string int2Str(int x).原创 2021-08-29 08:40:48 · 90 阅读 · 0 评论 -
leetcode70假设你正在爬楼梯。需要 n 阶你才能到达楼顶。每次你可以爬 1 或 2 个台阶。你有多少种不同的方法可以爬到楼顶呢?
class Solution {public: int climbStairs(int n) { // 1 初始化数组 std::vector<int> f(n); // 2 定义边界条件 if (n == 1) { return 1; } if (n == 2) { return 2; }.原创 2021-08-27 07:15:08 · 359 阅读 · 0 评论 -
卡特兰数列
由于最近怒刷笔试题遇到了很多关于卡特兰数列的问题于是写这篇文章,算是做个笔记吧。1卡特兰数列的定义: 是组合数学中一个常出现在各种计数问题中出现的数列。由以比利时的数学家欧仁·查理·卡塔兰 (1814–1894)命名。 2卡特兰树列的前几项: 1, 2, 5, 14, 42, 132, 429, 1430, 4862, 16796。 3卡特兰数列的推导公式: 令h原创 2015-05-22 02:35:48 · 1101 阅读 · 0 评论