![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
leetcode
eclipSYcn
helloworld
展开
-
Leetcode8_String to Integer (atoi)
8. String to Integer (atoi)题目描述: Implement atoi to convert a string to an integer. Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask you原创 2017-07-26 16:02:03 · 428 阅读 · 0 评论 -
leetcode10_Regular Expression Matching
10. Regular Expression Matching题目描述: ‘.’ Matches any single character. ‘*’ Matches zero or more of the preceding element. The matching should cover the entire input string (not partial).原创 2017-07-27 16:31:31 · 460 阅读 · 0 评论 -
Leetcode 12 integer-to-roman
https://leetcode.com/problems/integer-to-roman/discuss/ Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range from 1 to 3999.解释: 罗马数字共有7个,即I(1)、V(5)、X(10)、L(50)原创 2017-12-14 13:37:03 · 303 阅读 · 0 评论 -
leetcode 33 Search in Rotated Sorted Array (c++)
记录一下思路: 时间复杂度要求log n,所以二分查找。 总是对二分的左右指针小于等于或者小于有疑惑。 思考过程: 1、要二分查找,首先要找到是在左侧查找还是右侧查找。 2、因为是循环数组,所以有一定规律。必然有一侧的是递增序列。 3、在递增序列中可以比较target是否在递增序列中。 4、如果在就继续普通二分,不在就在另一侧找递增序列。 5、最后剩余2-3个数,考虑一下小于等于。原创 2018-05-05 15:12:31 · 233 阅读 · 0 评论 -
Leetcode 38 Count and Say
一开始题没读懂: n是代表迭代次数n = 1;返回”1”。n = 2;查”1”,代表1个1。返回“11”.n = 3;查”11“,代表2个1。返回”21”.n = 4;查”21”,代表1个2,1个1。返回”1211”。… 解题思路: 1、没什么说的,递归查,c++ string 可以用+来连接。 2、对于字符串最后一个位置的判断。有两种方法,一种是让最后一个字符在循环之后处理...原创 2018-05-05 15:20:20 · 231 阅读 · 0 评论 -
39. 组合总和 + 40.
菜鸟级别,还需要参考别人的思路: https://blog.csdn.net/zr1076311296/article/details/51374923思路:递归,但是具体实现细节还是需要参考别人的代码。 递归整体思路应该就是昨天和今天这两个。一个是带返回值,一个在参数传递时改变。class Solution {public: vector<vector<in...原创 2018-05-06 16:04:35 · 1034 阅读 · 0 评论 -
41. 缺失的第一个正数
思路:将数值大于0且小于数组长度的数值nums[i],放入 i-1 的位置, 最后遍历数组,若nums[i] != i+1,则return i + 1; 注意: 为了避免两次交换值相同,造成同一位置无限循环,所以加入nums[nums[i] - 1] != nums[i]。既考虑同一位置,也考虑不同位置同一数值的避免交换。class Solution {public: int fi...原创 2018-05-14 23:10:02 · 540 阅读 · 0 评论