08 2020 档案
摘要:一:解题思路 采用递归的思想来做。 二:完整代码示例 (C++版和Java版) C++代码如下: class Solution { public: ListNode* removeZeroSumSublists(ListNode* head) { if (head == NULL) return N
阅读全文
摘要:一:解题思路 以二叉树的广度优先的思想来做,即二叉树的层序遍历的思想来做,只把没一层的最后一个结点放入到最后的集合当中。 二:完整代码示例 (C++版和Java版) C++: class Solution { public: vector<int> rightSideView(TreeNode* r
阅读全文
摘要:一:解题思路 这道题目和 leetcode112 在二叉树中是否存在指定和类似,leetcode112 这个题目是判断存在性,而这个题目是求出符合条件的路径总数量,可以放在一起学习。 Time:O(n),Space:O(n) 二:完整代码示例 (C++版和Java版) C++: class Solu
阅读全文
摘要:一:解题思路 题目告诉我们的是整数数组,则我们可以将整数和对应的下标一一映射。 先遍历一遍数组,将正整数放在对应的位置上,然后再遍历一遍数组求出缺失的的第一个正数数字。 二:完整代码示例 (C++版和Java版) C++: class Solution { public: int firstMiss
阅读全文
摘要:一:解题思路 举例:一个ip地址为10.0.3.193 转化后的整数为:167773121 二:完整代码示例 (C++版和Java版) Ip地址转化为整数 C++代码: int ipToInt(string s) { int ret = 0; int num = 0; for (int i = 0;
阅读全文
摘要:一:解题思路 二:完整代码示例 (C++版和Java版) C++代码: #include <iostream> #include <string> #include <vector> using namespace std; int main() { string str = ""; while (
阅读全文
摘要:一:解题思路 二:完整代码示例 (C++版和Java版) C++代码: #include <iostream> using namespace std; int main() { int i = 0; int j = 0; int k = 0; int num = 0; while (cin >>
阅读全文
摘要:一:解题思路 二:完整代码示例 (C++版和Java版) C++代码: #include <iostream> #include <vector> #include <string> #include <map> using namespace std; int main() { string st
阅读全文
摘要:一:解题思路 二:完整代码示例 (C++版和Java版) C++代码: #include <iostream> #include <vector> #include <string> using namespace std; int main() { string str = ""; while (
阅读全文
摘要:一:解题思路 二:完整代码示例 (C++版和Java版) C++代码: #include <iostream> #include <string> #include <vector> #include <algorithm> using namespace std; bool isBrother(s
阅读全文
摘要:一:解题思路 二:完整代码示例 (C++版和Java版) C++代码: #include <iostream> #include <string> #include <vector> #include <algorithm> using namespace std; void encryString
阅读全文
摘要:一:解题思路 这道题目和leetcode 151 有些类似,可以放在一起进行学习。 二:完整代码示例 (C++版和Java版) C++代码在牛客网上面 AC 90%,有点奇怪。 C++代码: #include <iostream> #include <string> #include <vector
阅读全文
摘要:一:解题思路 这道题目和 leetcode5 很类似,可以放在一起进行学习,这里给出 Time:O(n^2),Space:O(n^2) 动态规划版的解法。 二:完整代码示例 (C++版和Java版) C++代码: #include <iostream> #include <string> #incl
阅读全文
摘要:一:解题思路 二:完整代码示例 (C++版和Java版) C++代码: #include <iostream> #include <string> #include <algorithm> using namespace std; int main() { string str = ""; whil
阅读全文
摘要:一:解题思路 二:完整代码示例 (C++版和Java版) C++代码: #include <iostream> using namespace std; int main() { int k = 0; int N = 0; int num = 0; while (cin >> k) { num =
阅读全文
摘要:一:解题思路 这道题目的本质就是求斐波那契数列的第n项。 二:完整代码示例 (C++版和Java版) C++代码: #include <iostream> using namespace std; int main() { int months = 0; while (cin >> months)
阅读全文
摘要:一:解题思路 二:完整代码示例 (C++版和Java版) C++代码: #include <iostream> #include <cmath> using namespace std; int main() { int n = 0; while (cin >> n) { double sum =
阅读全文
摘要:一:解题思路 注意输入字符串str中,如果包含空格,则需要用getline(cin,str) 二:完整代码示例 (C++版和Java版) C++代码: #include <iostream> #include <string> using namespace std; int main() { st
阅读全文
摘要:一:解题思路 子网掩码是用来判断任意两台计算机的IP地址是否属于同一子网络的根据。子网掩码与IP地址结构相同,是32位二进制数,其中网络号部分全为“1”和主机号部分全为“0”。利用子网掩码可以判断两台主机是否中同一子网中。若两台主机的IP地址分别与它们的子网掩码相“与”后的结果相同,则说明这两台主机
阅读全文
摘要:1.基于QT4的简易计算器小软件 免费下载链接为:https://download.csdn.net/download/weixin_42136255/12688789 2.基于QT4的简易文本编辑器小软件 免费下载链接为:https://download.csdn.net/download/wei
阅读全文
摘要:一:解题思路 这道题目的关键的地方在于,让出现字母次数最多的字母,漂亮度最大,其次依次递减。 二:完整代码示例 (C++版和Java版) C++代码: #include <iostream> #include <string> #include <algorithm> using namespace
阅读全文
摘要:一:解题思路 这道题目需要注意的是,一个中文字符是占2个字节的。用C/C++ 中原生的数组即可以做到按字节访问的,数组本质就是按指针运算进行的,而指针运算的本质就是按字节进行算偏移量。 二:完整代码示例 (C++版和Java版) C++代码: #include <iostream> #include
阅读全文
摘要:一:解题思路 这道题目和leetode 19 有些类似,可以放在一起进行学习。这个题目需要自己创建单链表,并且还有倒数第0个,这个我个人认为没有必要。我保持和leetcode 19一样的写法。 二:完整代码示例 (C++版和Java版) C++代码: #include <iostream> #inc
阅读全文
摘要:一:解题思路 这道题目和leetcode72题,基本上是一样的,可以放在一起进行学习。 二:完整代码示例 (C++版和Java版) C++: #include <iostream> #include <string> #include <vector> #include <algorithm> us
阅读全文
摘要:一:解题思路 二:完整代码示例 (C++版和Java版) C++: #include <iostream> #include <vector> #include <string> #include <algorithm> using namespace std; int count(int n) {
阅读全文
摘要:一:解题思路 二:完整代码示例 (C++版和Java版) C++代码: #include <iostream> #include <vector> #include <numeric> #include <algorithm> using namespace std; int count(int n
阅读全文
摘要:一:解题思路 这道题目和 leetcode67 二进制求和 有些类似,可以放在一起进行学习。 二:完整代码示例 (C++版和Java版) C++: #include <iostream> #include <string> #include <algorithm> using namespace s
阅读全文
摘要:一:解题思路 二:完整代码示例 (C++版和Java版) C++: #include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { int n = 0; int k = 0; w
阅读全文
摘要:一:解题思路 这道题目和 leetcode387 类似的,可以放在一起进行学习。 二:完整代码示例 (C++版和Java版) C++: #include <iostream> #include <vector> #include <string> using namespace std; void
阅读全文
摘要:一:解题思路 这道题目首先要知道怎么样判断一个数是否为素数,然后再去求查找组成一个偶数最接近的两个素数。 二:完整代码示例 (C++版和Java版) C++: #include <iostream> #include <cmath> using namespace std; bool isPrime
阅读全文
摘要:一:解题思路 f(m,n) 为m个苹果,n个盘子的方法数目。 递归出口说明:当m=0 || n=1 只有一种放法。 当n>m时:必定至少有n-m个盘子永远空着,去掉他们对摆放苹果数目不产生影响。即 if(n>m) f(m,n)=f(m,m) 当n<=m时:不同的方法可以分成2类: 1.至少一个盘子空
阅读全文
摘要:一:解题思路 这道题目和 leetcode 191 一样的,可以放在一起学习。 二:完整代码示例 (C++版和Java版) C++: #include <iostream> using namespace std; int theNumberOfOne(int n) { int counts = 0
阅读全文
摘要:一:解题思路 二:完整代码示例 (C++版和Java版) C++代码: #include <iostream> #include <string> using namespace std; int main() { string s = ""; int n = 0; while (cin >> s
阅读全文
摘要:一:解题思路 二:完整代码示例 (C++版和Java版) C++代码: #include <iostream> #include <cstring> using namespace std; void selectSong(int nums, const char* str) { int curre
阅读全文
摘要:一:解题思路 方法一:暴力破解法 方法二:动态规划 二:完整代码示例 (C++版和Java版) 方法一C++: #include <iostream> #include <vector> #include <string> #include <algorithm> using namespace s
阅读全文
摘要:一:解题思路 这道题目可以扩展为:从0到n中,任意选出m个数字,然后任意通过加减乘除的组合,得到一个定值,求是否存在这样的组合? 二:完整代码示例 (C++版和Java版) C++代码: #include <iostream> #include <vector> #include <algorith
阅读全文
摘要:一:解题思路 这道题目考察了稳定排序。 二:完整代码示例 (C++版和Java版) C++代码如下: #include <iostream> #include <vector> #include <string> #include <algorithm> using namespace std; s
阅读全文
摘要:一:解题思路 二:完整代码示例 (C++版和Java版) C++代码: #include <iostream> #include <vector> using namespace std; int main() { int row1=0; int col1=0; int col2=0; while(
阅读全文
摘要:一:解题思路 二:完整代码示例 (C++版和Java版) C++代码: #include <iostream> using namespace std; int main() { int n = 0; while (cin >> n) { for (int i = 0; i < 20; i++) {
阅读全文

浙公网安备 33010602011771号