摘要:
这道题目和leetcode88 合并2个有序数组有点类似,可以放在一起练习。 C++代码如下: #include<iostream> #include<vector> #include <set> #include <algorithm> using namespace std; int main( 阅读全文
posted @ 2020-07-30 22:06
repinkply
阅读(167)
评论(0)
推荐(0)
摘要:
这道题目是不是从长字符串中匹配子串的问题,而是一个更简单的问题。 C++代码如下: #include<iostream> #include<string> using namespace std; int main() { string sShort = ""; string sLong = ""; 阅读全文
posted @ 2020-07-30 21:34
repinkply
阅读(610)
评论(0)
推荐(0)
摘要:
C++代码: #include<iostream> #include<string> using namespace std; int main() { char ch='0'; int a = 0; int b =0; while (cin >> a >> ch >> b) { while (a 阅读全文
posted @ 2020-07-30 20:50
repinkply
阅读(583)
评论(0)
推荐(0)
摘要:
这道题目和leetcode5 最长回文子串 是一样的。这里需要强调一点就是,C++中 string类中,substr(a,b) a是要截取字符串的起始坐标,b是指要截取字符串的长度。Java String类中 substring(a,b)中 a的含义一样,但是b是要截取字符串的尾坐标,这个和C++ 阅读全文
posted @ 2020-07-30 18:32
repinkply
阅读(292)
评论(0)
推荐(0)
摘要:
C++代码如下: #include <iostream> #include <algorithm> using namespace std; int main() { int n = 0; while (cin >> n) { int count = 0; int maxCount = 0; whi 阅读全文
posted @ 2020-07-30 17:23
repinkply
阅读(229)
评论(0)
推荐(0)
摘要:
一:解题思路 方法一:之前做过一道求一个正整数二进制中1的个数的题目,利用这个题目为基础,然后遍历从1-n 这n+1 个数字。Time:O(n*k),Space:O(1) 方法二:利用动态规划的思想来做,递推公式为:d[i]=d[i&(i-1)]+1。Time:O(n),Space:O(1) 二:完 阅读全文
posted @ 2020-07-30 16:54
repinkply
阅读(228)
评论(0)
推荐(0)
摘要:
C++代码如下: #include <iostream> #include <string> using namespace std; int main() { string s=""; while (getline(cin, s)) { int val = 0; int len = s.size( 阅读全文
posted @ 2020-07-30 15:43
repinkply
阅读(620)
评论(0)
推荐(0)

浙公网安备 33010602011771号