上一页 1 ··· 10 11 12 13 14 15 16 17 18 ··· 58 下一页
摘要: #include<iostream> using namespace std; class parent { public: parent() { cout << "父类构造" << endl; } ~parent() { cout << "父类析构" << endl; } }; class chi 阅读全文
posted @ 2020-05-13 16:55 知道了呀~ 阅读(435) 评论(0) 推荐(0) 编辑
摘要: 当一个元素要入栈时,我们取当前辅助栈的栈顶存储的最小值,与当前元素比较得出最小值,将这个最小值插入辅助栈中(min_stack.push(min(x,min_stack.top())) 当一个元素要出栈时,我们把辅助栈的栈顶元素也一并弹出; 在任意一个时刻,栈内元素的最小值就存储在辅助栈的栈顶元素中 阅读全文
posted @ 2020-05-13 15:11 知道了呀~ 阅读(223) 评论(0) 推荐(0) 编辑
摘要: dfs递归枚举每个点分片段的数字是否合法 class Solution { public: bool isValid(string ip) { int val = stoi(ip); if (val > 255) return false; if (ip.size() >= 2 && ip[0] = 阅读全文
posted @ 2020-05-13 14:41 知道了呀~ 阅读(248) 评论(0) 推荐(0) 编辑
摘要: 先用栈判断括号匹配,在把所有匹配的括号标记为0,然后求最长的0序列 class Solution { public: int longestValidParentheses(string s) { int len = s.length(); int ans = 0; stack<int>p; for 阅读全文
posted @ 2020-05-13 10:30 知道了呀~ 阅读(228) 评论(0) 推荐(0) 编辑
摘要: 简单介绍: 环形缓冲区就是在最开始的时候申请一个大buffer,有一个读指针,一个写指针,随着数据写入和读取改变读写指针,具体分为三总情况: 1、是读写速度差不多,这种情况比较简单。 2、写的很快读的慢、这种情况写指针很快回头追上了读指针,这时候就会出现写buffer覆盖掉读指针的内存块,如果还继续 阅读全文
posted @ 2020-05-09 17:13 知道了呀~ 阅读(4159) 评论(0) 推荐(0) 编辑
摘要: 重点介绍一下resize()扩容和reserve()两个函数 resize() resize()扩容的默认构造的方式是0, 之后插入按照1 2 4 8 16 二倍扩容。注(GCC是二倍扩容,VS13是1.5倍扩容。原因可以考虑内存碎片和伙伴系统,内存的浪费)。 扩容后是一片新的内存,需要把旧内存空间 阅读全文
posted @ 2020-05-08 10:02 知道了呀~ 阅读(6412) 评论(0) 推荐(1) 编辑
摘要: 一、数组模拟栈 #include <iostream> #include<string.h> #include<string> #include<stdio.h> #include<vector> #include<math.h> using namespace std; template<type 阅读全文
posted @ 2020-05-07 17:55 知道了呀~ 阅读(258) 评论(0) 推荐(0) 编辑
摘要: 因为要求时间和空间都要在O(n)内,所以用下标标记每个数是否出现,然后再顺序遍历,输出第一个下标未被标记的数,这种方法是不行的 应该遍历一边数组,判断 nums[nums[i] - 1] != nums[i](下标从0开始),如果不在,则交换num[i]和num[num[i]-1]。 我们的思路是把 阅读全文
posted @ 2020-05-07 16:44 知道了呀~ 阅读(135) 评论(0) 推荐(0) 编辑
摘要: 中序遍历输出二叉树是一个递增的序列 /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val 阅读全文
posted @ 2020-05-07 16:18 知道了呀~ 阅读(226) 评论(0) 推荐(0) 编辑
摘要: 矩阵快速幂 #include <iostream> #include<string.h> #include<stdio.h> using namespace std; class Solution { public: typedef long long ll; const ll mod = 1000 阅读全文
posted @ 2020-05-06 17:05 知道了呀~ 阅读(280) 评论(0) 推荐(0) 编辑
上一页 1 ··· 10 11 12 13 14 15 16 17 18 ··· 58 下一页