01 2021 档案

摘要:#include <bits/stdc++.h> using namespace std; /* run this program using the console pauser or add your own getch, system("pause") or input loop */ boo 阅读全文
posted @ 2021-01-28 21:24 然终酒肆 阅读(77) 评论(0) 推荐(0) 编辑
摘要:写的很好!!!: https://blog.csdn.net/liangzhaoyang1/article/details/51413108 阅读全文
posted @ 2021-01-26 15:33 然终酒肆 阅读(49) 评论(0) 推荐(0) 编辑
摘要:怎么我搜到的都东拼西凑你抄我我抄你呢 真正初始化只用这一句就行啊: vector<vector<int> > vec(m, vector<int>(n, 0));//初始化一个m行n列的元素值全为0的二维数组 这是利用了vector的构造方法 另: 二维数组vector的插入 阅读全文
posted @ 2021-01-26 14:40 然终酒肆 阅读(8597) 评论(0) 推荐(4) 编辑
摘要:c++: class Solution { public: string addBinary(string a, string b) { if(a == "") return b; if(b == "") return a; int i = a.size() - 1; int j = b.size( 阅读全文
posted @ 2021-01-25 23:44 然终酒肆 阅读(63) 评论(0) 推荐(0) 编辑
摘要:class Solution { public: vector<int> plusOne(vector<int>& digits) { int len = digits.size(); for(int i = len -1;i>=0;i--) { if(digits[i] != 9) { digit 阅读全文
posted @ 2021-01-25 22:37 然终酒肆 阅读(81) 评论(0) 推荐(0) 编辑
摘要:出题人语死早,并没有叙述清楚 值得注意的是,“abc ”这个字符串是有单词存在的 所以从尾部判断的时候还要再看一下前边 class Solution { public: int lengthOfLastWord(string s) { int len = s.size(); int rear = l 阅读全文
posted @ 2021-01-25 21:56 然终酒肆 阅读(38) 评论(0) 推荐(0) 编辑
摘要:class Solution { public: int maxSubArray(vector<int>& nums) { int res = nums[0]; int sum = 0; for( int num : nums ) { if(sum > 0) sum+=num; else sum = 阅读全文
posted @ 2021-01-25 21:26 然终酒肆 阅读(51) 评论(0) 推荐(0) 编辑
摘要:迭代: class Solution { public: string countAndSay(int n) { string ans ="1"; n-=1; int s_index;//开始的索引 string temp; while(n--) { temp = ""; s_index =0; f 阅读全文
posted @ 2021-01-25 21:03 然终酒肆 阅读(50) 评论(0) 推荐(0) 编辑
摘要:class Solution { public: int removeDuplicates(vector<int>& nums) { int i = 0; int len = nums.size(); if(len==0) return 0; for(int j =1;j<len;j++ ) { i 阅读全文
posted @ 2021-01-22 23:42 然终酒肆 阅读(66) 评论(0) 推荐(0) 编辑
摘要:/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode() : val(0), next(nullptr) {} * ListNode(int x) : 阅读全文
posted @ 2021-01-22 23:25 然终酒肆 阅读(51) 评论(0) 推荐(0) 编辑
摘要:模拟面试的时候,遇到了这种题 确实是简单至极的题目 但是我 忘了栈用stl怎么写。又懒得用结构体写栈。 自己用vector造了一个栈。。。 我猜压根没像我这么写的 就很快乐 class Solution { public: bool isValid(string s) { if(s == "") r 阅读全文
posted @ 2021-01-21 23:32 然终酒肆 阅读(45) 评论(0) 推荐(0) 编辑
摘要:class Solution { public: string longestCommonPrefix(vector<string>& strs) { if(!strs.size()) return ""; else if(strs.size() == 1 ) return strs[0]; els 阅读全文
posted @ 2021-01-21 22:23 然终酒肆 阅读(56) 评论(0) 推荐(0) 编辑
摘要:class Solution { public boolean isPalindrome(int x) { if(x < 0) return false; int cur = 0; int num = x; while(num != 0) { cur = cur * 10 + num % 10; n 阅读全文
posted @ 2021-01-18 14:52 然终酒肆 阅读(57) 评论(0) 推荐(0) 编辑
摘要:这是一道再水不过的题。但是这道题其实会引起一些思考的 这道题解法一定很多 初见这道题时,大多数人想的思路应该就是直接暴力 数字转字符串。但是这样未免太低级了。 在高级点就是,反转其实可以用栈。 一步一步用vector 推进去 或者用栈推进去然后输出就行了 中间要判断是否溢出,还有0和负号的一些处理 阅读全文
posted @ 2021-01-18 14:38 然终酒肆 阅读(64) 评论(0) 推荐(0) 编辑
摘要:https://www.cnblogs.com/knowledgesea/archive/2013/01/02/2841588.html 阅读全文
posted @ 2021-01-16 21:06 然终酒肆 阅读(52) 评论(0) 推荐(0) 编辑
摘要:百忙之中刷一道算法题 一眼看出来就是并查集了 class Solution { public: int f[20000+10]; int find(int x) { if(f[x] != x) f[x] = find(f[x]); return f[x]; } int removeStones(ve 阅读全文
posted @ 2021-01-15 19:01 然终酒肆 阅读(84) 评论(0) 推荐(0) 编辑
摘要:在做目录的时候。就需要插入一个分页符作为目录的空白页 插入分页符: 一般插入选项就有 但是如何删除分页符呢。。。 首先,ctrl+f 打开查找替换界面 点击特殊字符 点击之后,发现 这个^m就是分页符的符号 我们啥也不做,让它替换为空格。就相当于删除了分页符 阅读全文
posted @ 2021-01-14 09:39 然终酒肆 阅读(679) 评论(0) 推荐(0) 编辑
摘要:#include<algorithm> #include<map> #include<vector> #include<string> #include<iostream> #include<stack> using namespace std; #define max 203 #define in 阅读全文
posted @ 2021-01-10 16:26 然终酒肆 阅读(72) 评论(0) 推荐(0) 编辑
摘要:原题: 代码(dfs): #include<iostream> #include<vector> #include<unordered_map> #include<limits.h> using namespace std; int mindis[201]; vector <int> path; i 阅读全文
posted @ 2021-01-09 18:06 然终酒肆 阅读(90) 评论(0) 推荐(0) 编辑
摘要:python方法重载 无法像c++ c#那样实现 如果写相同名称但参数不同的方法,会实现函数的覆盖 只能逻辑实现 阅读全文
posted @ 2021-01-08 16:47 然终酒肆 阅读(73) 评论(0) 推荐(0) 编辑
摘要:我们先建立一个表 EMP(15行): 如果想查询所有数据,很简单 select * from EMP; 这样就能查询到EMP的所有数据 在了解多表查询之前 我们应该先复习一下数学中笛卡尔积的概念 比如一个集合有(1,2,3)三个元素 另一个集合有(4,5,6)三个元素 他们的笛卡尔积 其实有3*3 阅读全文
posted @ 2021-01-02 15:49 然终酒肆 阅读(120) 评论(0) 推荐(0) 编辑
摘要:1. A warning:comparison between signed and unsigned integer expressions [-Wsign-compare]:有符号数和无符号数的比较警告 为什么出错呢 很多时候你必须声明一下 unsigned int 如果不声明,有时候进行比较, 阅读全文
posted @ 2021-01-01 21:08 然终酒肆 阅读(336) 评论(0) 推荐(0) 编辑
摘要:加入: -std=c++11即可使用c++11标准 阅读全文
posted @ 2021-01-01 20:51 然终酒肆 阅读(413) 评论(0) 推荐(0) 编辑
摘要:很多时候,用邻接矩阵(二维数组)存图,如果是稀疏图,一般会造成很大的空间浪费。 c++11 的vector容器新增了 emplace_back方法。一般和push_back用法没有大的不同,但是性能要好。 最主要的是,据我研究发现 emplace_back()方法可以像邻接表一样给数组元素链接上邻居 阅读全文
posted @ 2021-01-01 20:47 然终酒肆 阅读(134) 评论(0) 推荐(0) 编辑
摘要:在vector里,push_back和emplace_back都是向容器尾部添加新元素。 从用法来说,都是一样的。但是 emplace_back是c++11新增的,有些竞赛的评测机很可能不支持。而emplace_back的实现是比push_back要好的,push_back本质上是又创建了一个新元素 阅读全文
posted @ 2021-01-01 15:42 然终酒肆 阅读(381) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示