2019年2月27日

pta7-1 Maximum Subsequence Sum

摘要: 认真学数据结构算法了,想着以c为基础的好多读明白代码就可以了,不一定非要用c这么复杂来写,考研的时候再说,现在就先用STL写。 PTA对程序的严谨性还是高啊。最后0和负数混杂和单纯负数都得分类。 阅读全文

posted @ 2019-02-27 17:49 Gavinthoms 阅读(85) 评论(0) 推荐(0) 编辑

2019年2月21日

c++向量,迭代器

摘要: 迭代器本身是指针,向量也可以按照数组来访问。 阅读全文

posted @ 2019-02-21 08:48 Gavinthoms 阅读(187) 评论(0) 推荐(0) 编辑

27. Remove Element

摘要: class Solution { public: int removeElement(vector& nums, int val) { int s=0; for(int i=0;i<nums.size();i++) { if(nums[i]!=val) ... 阅读全文

posted @ 2019-02-21 08:45 Gavinthoms 阅读(83) 评论(0) 推荐(0) 编辑

2019年2月16日

26. Remove Duplicates from Sorted Array

摘要: 一开始写的是num[i]和nums[i+1],存在数组越界的问题,以后多用i-1避免数组越界,多亏北航的一个学长。 阅读全文

posted @ 2019-02-16 10:25 Gavinthoms 阅读(119) 评论(0) 推荐(0) 编辑

2019年1月29日

第二讲.线性结构

摘要: 假设一个队列有六个格子,队列的front和rear指针相差有0,1,2,3,4,5六种情况,队列的存储则有0,1,2,3,4,5,6个元素这七种情况,所以当front==rear的时候,无法判断队满还是队空,必然产生矛盾。 阅读全文

posted @ 2019-01-29 11:45 Gavinthoms 阅读(127) 评论(0) 推荐(0) 编辑

2019年1月23日

leetcode19.Remove Nth Node From End of List

摘要: 回家的火车上坐了这道题,因为是倒序删除节点,所以可以遍历链表把倒序变为正序,一开始的思路就是计算链表的节点数然后减去后面的数字,实际写的时候发现还要碰到好多不同的情况 题目中没有说有没有头结点,也有可能是我没看到,实际发现测试样例还是有一些特殊情况,分开用if else if语句分开情况就好。最经常 阅读全文

posted @ 2019-01-23 16:47 Gavinthoms 阅读(86) 评论(0) 推荐(0) 编辑

2019年1月14日

bupt F M密码注册规则

摘要: #include #include int main() { char a[55]; while(scanf("%s",a)) { if(a[0]=='E'&&a[1]=='N'&&a[2]=='D') break; else { int condition_a=0; int condition_1=0; ... 阅读全文

posted @ 2019-01-14 19:55 Gavinthoms 阅读(128) 评论(0) 推荐(0) 编辑

2019年1月9日

calc the sum

摘要: 要放那么大的数字要用字符串,用一个递归就行。 阅读全文

posted @ 2019-01-09 22:05 Gavinthoms 阅读(184) 评论(0) 推荐(0) 编辑

2019年1月8日

leetcode.11. Container With Most Water

摘要: 转向c++了,底乘高,低最大,面积再想大一点就得 保证高不断拓高,低的那一边就需要往上升到比原来高的地方才能提高容器。 阅读全文

posted @ 2019-01-08 12:30 Gavinthoms 阅读(58) 评论(0) 推荐(0) 编辑

2019年1月6日

leetcode 7. Reverse Integer

摘要: 代码很好写,需要考虑呢的是反置的数字超出int 型的时候就要返回0.这里参考了https://www.cnblogs.com/ariel-dreamland/p/8706403.html这篇博客。 然后把leetcode里面默认给的数据类型也改了 Your input 1534236469 Your 阅读全文

posted @ 2019-01-06 21:29 Gavinthoms 阅读(89) 评论(0) 推荐(0) 编辑

导航