- 博客(165)
- 资源 (5)
- 收藏
- 关注

原创 PAT系列索引
1003. Emergencyhttp://blog.youkuaiyun.com/staibin/article/details/211950611004. Counting Leaveshttp://blog.youkuaiyun.com/staibin/article/details/211957511006. Sign I
2014-03-13 23:05:20
594

转载 杭电ACM分类
基础题:1000、1001、1004、1005、1008、1012、1013、1014、1017、1019、1021、1028、1029、1032、1037、1040、1048、1056、1058、1061、1070、1076、1089、1090、1091、1092、1093、1094、1095、1096、1097、1098、1106、1108、1157、1163、1164、1170、1194、1
2014-02-14 11:03:56
675

转载 匈牙利命名法
http://hi.baidu.com/chaosaco/item/68573af2e7dd1610d7ff8ce6 a Array 数组 b BOOL (int) 布尔(整数
2014-02-09 10:53:07
555
原创 Google代码规范之C++
You may need to read in http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml。
2014-07-28 12:57:53
840
原创 Path Sum
path-sum递归:如果使用递归,需要明确递归的结束条件,结束条件分为几类。递归的模式为:Type f(...) { if 满足结束条件1 return x; if 满足结束条件2 return x; ...... 递归表达式}
2014-07-28 11:15:30
712
原创 Single Number II
题目Given an array of integers, every element appears three times except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you implement it wit
2014-07-23 15:31:58
651
原创 Single Number
//空间O(n), 时间O(nlogn)class Solution {public: int singleNumber(int A[], int n) { set se; for (int i = 0; i < n; ++i) { auto it = se.find(A[i]); if (it == s
2014-07-21 22:18:28
645
原创 Binary Tree Postorder Traversal
CODE见 http://blog.youkuaiyun.com/staibin/article/details/37932173 中的后序遍历。
2014-07-18 21:09:15
497
原创 Binary Tree Preorder Traversal
题目分析复杂度输入CODE/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL)
2014-07-17 11:49:29
496
原创 Insertion Sort List
题目CODE/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ typede
2014-07-16 11:22:47
568
原创 单链表C语言实现(Need edition)
CODE:Cyuyan#include #include #include typedef int ElemType;typedef struct _ListNode{ ElemType data; struct ListNode* next;}ListNode;ListNode * initSList();int isEmpty(ListNode *hea
2014-07-11 16:01:53
855
原创 自定义map比较规则及函数调用
参考文章:http://blog.youkuaiyun.com/challenge_c_plusplus/article/details/7429963#include #include #include #include using namespace std;bool my_compare(const string &str1, const string &str2){ retu
2014-07-04 15:23:04
1838
转载 指针和指针的引用及双指针
原文链接: http://blog.youkuaiyun.com/ztz0223/article/details/1628669
2014-07-03 22:23:47
772
原创 Evaluate Reverse Polish Notation
题目Evaluate the value of an arithmetic expression in Reverse Polish Notation.Valid operators are +, -, *, /. Each operand may be an integer or another expression.Some examples: ["2
2014-07-02 16:47:24
451
原创 Two Sum
题目Given an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two numbers such that they add up to the tar
2014-07-01 10:35:14
632
原创 1075. PAT Judge
题目链接:http://pat.zju.edu.cn/contests/pat-a-practise/1075/* * 最后一个测试点错误原因:对成绩初始化时,错误。。。见具体代码处解释 * * 需要解决的几个问题: * 1. student应包含哪些成员,什么类型 * 2. 如何实现排序 * 3. 输入的成绩如何映射到student上,显然Hash。 * 本次使用vec
2014-03-21 23:12:26
1066
原创 1071. Speech Patterns
题目链接:http://pat.zju.edu.cn/contests/pat-a-practise/1071/* * map:自动创建机制。 * transform:将某操作应用于指定范围的每个元素,类似于foreach。 * 定义在头文件algorithm中。 * ::tolower:将一个字符大写变小写。 */ #pragma warning(disable: 4786)
2014-03-21 23:11:12
889
原创 1070. Mooncake
题目链接:http://pat.zju.edu.cn/contests/pat-a-practise/1070/* * 贪心问题 * 坑:数量为double。这样符合实际问题,但是题目给的示例及题目信息尾 * 表明为double。 */#include #include #include using namespace std;struct Mooncake{ dou
2014-03-21 22:12:07
810
原创 1067. Sort with Swap(0,*)
题目链接:http://pat.zju.edu.cn/contests/pat-a-practise/1067/* * 参考:http://biaobiaoqi.me/blog/2013/10/08/pat-1065-pat-1068/ * * 分析示例、找准方法: 把问题抽象为圈。 * dfs,并查集都可计算圈内元素个数。因此题结构简单,适合用dfs思想。 * 设一个圈有m个元素
2014-03-21 22:10:26
708
原创 1066. Root of AVL Tree
题目链接:http://pat.zju.edu.cn/contests/pat-a-practise/1066考察AVL树的操作,大家从理论上都懂得过程,但实现起来。。。不知道怎么下手啊/* * 参考:http://biaobiaoqi.me/blog/2013/10/08/pat-1065-pat-1068/ * * 考察AVL树的建立,调整操作,树的高度的更新。 * 需特别注
2014-03-21 22:09:15
707
原创 1064. Complete Binary Search Tree
题目链接:http://pat.zju.edu.cn/contests/pat-a-practise/1064按正常思路,重点仍在建树,需要结合完全二叉树与二叉搜索树的性质,确定跟节点的位置。另外,其他思路见代码注释。/* * 参考:http://biaobiaoqi.me/blog/2013/08/31/pat-1061-pat-1064/ * * 使用数组存放完全二叉树,
2014-03-21 22:07:17
751
原创 1063. Set Similarity
题目链接:http://pat.zju.edu.cn/contests/pat-a-practise/1063使用set,简单数学题。// set::find()找不到时返回的是set::end()//#pragma warning(disable: 4786)#include #include #include #include #include #include
2014-03-21 08:51:03
694
原创 1062. Talent and Virtue
题目链接:http://pat.zju.edu.cn/contests/pat-a-practise/1062德才论:按给定分类,然后进行排序。// 典型分类排序题#include #include #include #include #include #include #include #include #include #include #include #
2014-03-21 08:47:44
758
原创 1060. Are They Equal
题目链接:http://pat.zju.edu.cn/contests/pat-a-practise/1060转为科学计数法:输入没有固定格式,适合用char,读取一个字符,处理一个。 string适合输入格式固定,比如1073,科学计算表示。参考了newer的源码:http://blog.youkuaiyun.com/newner/article/details/9263993。
2014-03-21 08:43:25
664
原创 1059. Prime Factors
题目链接:http://pat.zju.edu.cn/contests/pat-a-practise/1059// 注意输入数据为1时特殊处理// 采取常规方法,先求出“所有”素数,再一次遍历。// 符合条件者入vector,最后输出。// #include #include #include #include #include #include #include #
2014-03-21 08:21:13
686
原创 1053. Path of Equal Weight
题目链接:http://pat.zju.edu.cn/contests/pat-a-practise/1053同一类型:路径长度、保存与给定值相同的路径长度、记录一定深度的路径、记录节点号/值。// 采用邻接表表示树// 用vector存储路径// 路径不止1一条,需用vector >存储所有路径// 输入时建树// 得到一个节点的所有子节点后,进行排序:按权值// dfs遍历
2014-03-21 08:14:05
782
原创 1052. Linked List Sorting
题目链接:http://pat.zju.edu.cn/contests/pat-a-practise/1052这个题目告诉我们:读题、理解题目、分析题目很重要。题目说只有1个链表了吗?题目说链表的结尾一定是NULL了吗?链表空的时候应该输出什么?另外,都注意到NULL定义为-1了。这个题目用hash的方法,很适合的。因此也可以试着用map。数组hash的方法见:
2014-03-19 22:02:01
809
转载 1051. Pop Sequence
题目链接:http://pat.zju.edu.cn/contests/pat-a-practise/1051栈的操作的检验// 孙佰贵#include #include #include using namespace std;int main(){ int M, N, K; scanf("%d%d%d",&M,&N,&K); for (int i = 0; i
2014-03-19 21:48:44
639
原创 1048. Find Coins
题目链接:http://pat.zju.edu.cn/contests/pat-a-practise/1048查询#include #include #include using namespace std;vectorcoin;int n, m;int FindBest(int i){ int l=i+1, r=coin.size()-1; while(l <=
2014-03-19 21:45:37
779
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人