
Leetcode
xiaoyisha
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
【双指针】Leetcode 实现strStr
给定一个haystack 字符串和一个 needle 字符串,在 haystack 字符串中找出 needle 字符串出现的第一个位置 (从0开始)。如果不存在,则返回-1。 int strStr(string haystack, string needle) { if(needle == "") return 0; int len1 = haysta...原创 2019-04-16 09:28:22 · 148 阅读 · 0 评论 -
Leetcode pow(x, n) 矩阵快速幂
实现pow(x,n),即计算 x 的 n 次幂函数。 -100.0 <x< 100.0 n是 32 位有符号整数,其数值范围是[−,− 1] 。 矩阵快速幂: double qPow(double x, int n){ double res = 1; while(n){ if(n&1) res *= x; ...原创 2019-04-14 19:30:23 · 350 阅读 · 0 评论 -
【递归 回溯】Leetcode 括号生成
给出n代表生成括号的对数,请你写出一个函数,使其能够生成所有可能的并且有效的括号组合。 例如,给出n=3,生成结果为: [ "((()))", "(()())", "(())()", "()(())", "()()()" ] 方法一:暴力法 vector<string> res; int n; vector<string> ge...原创 2019-04-14 19:56:23 · 154 阅读 · 0 评论