![](https://img-blog.csdnimg.cn/20201014180756916.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
PAT
等待不系之舟
我喜欢编程
展开
-
Maximum Subsequence Sum【PAT 1007题】---简单的动态规划
最大连续子序列和,动态规划的简单题,其实这个题不用动态规划的方法去理解算法也很简单,用sum存储遍历途中遇到的当前最大和,用temp存储当前处理的子序列和,如果temp>=0,则访问a[i]时,temp += a[i],但若temp是小于0的,则加上a[i]以后定然小于a[i],所以直接把temp更新为a[i],访问一个新的子序列,如果temp大于sum,则更新sum,以上就是解题思路,由于题目中转载 2015-03-15 23:46:47 · 330 阅读 · 0 评论 -
PAT 解题报告 1074. Reversing Linked List (25)
转载自http://tech-wonderland.net/blog/pat-1074-reversing-linked-list.html 1074. Reversing Linked List 题目描述: Given a constant K and a singly linked list L, you are supposed to reverse the links转载 2015-03-26 23:35:02 · 711 阅读 · 0 评论 -
02-线性结构3. Pop Sequence (25)
设置一个变量tmp,由1开始自增。当栈顶元素与输入的元素不匹配时将当前tmp入栈并tmp自加,当匹配时栈顶出栈。 来源:::http://blog.csdn.net/sup_heaven/article/details/20001385 [cpp] view plaincopy #include #include using n转载 2015-03-28 21:18:01 · 491 阅读 · 0 评论 -
03-树1. List Leaves (25)
#include #include #include using namespace std; #define MaxNum 10 typedef struct TreeNode{ int Data; int tLeft; int tRight; }*pNode, tNode; typedef struct TreeQueue{转载 2015-04-08 21:03:41 · 372 阅读 · 0 评论