- 博客(7)
- 收藏
- 关注
原创 lintcode第八题——旋转字符串
void rotateString(string &str, int offset) { // write your code here if (str.length() == offset || str.length() == 0) { return; } else if (str.l...
2019-08-08 18:24:21
212
原创 lintcode第七题——二叉树的序列化和反序列化
stringstream类知识点: <sstream>库定义了三种类:istringstream、ostringstream和stringstream,分别用来进行流的输入、输出和输入输出操作。 1.stringstream::str(); returns a string object with a copy of the current contents of the s...
2019-08-08 17:08:41
205
原创 lintcode第六题:合并排序数组
vector<int> mergeSortedArray(vector<int> &A, vector<int> &B) { // write your code here A.insert (A.end(),B.begin(),B.end()); sort(A.begin(),A.end(...
2019-07-13 17:36:26
203
原创 lintcode第5题:第K大元素
int kthLargestElement(int n, vector<int> &nums) { // write your code here int num = nums.size(); sort(nums.begin(), nums.end()); return nums[num-n]; }...
2019-07-13 16:46:52
282
原创 C++三个数组模板vector、数组、array
vector是一个动态sh数组,但付出的代价是效率比较低。vector<typeName> count(n_elem);size()——返回容器中元素的数目、begin()、end()。push_back( )将元素添加到矢量末尾。count.erase(count.begin(),count.begin()+ 2 );删除矢量中给定的区间的元素。count.insert(...
2019-07-13 16:01:48
252
原创 LintCode第四题:丑数
丑数的核心思想是:用已经生成的丑数chen乘2、3、5,求其最小值为新的丑数。int nthUglyNumber(int n) { // write your code here vector<int> count(1,1); int i2 = 0, i3 = 0, i5 = 0; while (count.size(...
2019-07-13 16:01:10
160
转载 c/c++常用开源库汇总
偶然发现的一个博客地址C/C++框架和库 (真的很强大):https://blog.youkuaiyun.com/xiaoxiaoyeyaya/article/details/42541419
2019-07-13 15:14:46
377
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅