
PAT/天梯赛/Leetcode
文章平均质量分 67
longtails
:(){ :|:& };: 术业专攻
展开
-
用go刷leetcode-导航
lt20 生成括号,回溯https://longtails.blog.youkuaiyun.com/article/details/122910119原创 2022-02-13 16:05:30 · 1820 阅读 · 0 评论 -
lt22. 括号生成
lt22. 括号生成回溯题解package lt100func generateParenthesis(n int) []string { return backTracing("", n, n)}/**回溯,因为只有两个符号1. () (的位置必须比)小,递归过程中保证了全部2. 没有到最后,(不能全部用光 if left==0 and right>1 可以直接跳过去3. 不需要验证合法性,因为剪枝完成后,只有有效的了*/func backTracing(result原创 2022-02-13 16:02:31 · 1762 阅读 · 0 评论 -
143. 重排链表
143. 重排链表给定一个单链表 L:L0→L1→…→Ln-1→Ln ,将其重新排列后变为: L0→Ln→L1→Ln-1→L2→Ln-2→…你不能只是单纯的改变节点内部的值,而是需要实际的进行节点交换。示例 1:给定链表 1->2->3->4, 重新排列为 1->4->2->3.示例 2:给定链表 1->2->3->4->5, 重新排列为 1->5->2->4->3.package mainimport原创 2021-04-09 00:22:36 · 347 阅读 · 0 评论 -
PAT_A 1102. Invert a Binary Tree (25)
1102. Invert a Binary Tree (25)1102.总结:初始化工作分离,单独出来。原创 2016-10-23 10:19:12 · 623 阅读 · 0 评论 -
PAT_A 1101. Quick Sort (25)
PAT-A-1101. Quick Sort (25)注意输出为0,第二行为空,需要输出一个回车原创 2016-10-20 23:18:39 · 507 阅读 · 0 评论 -
leetcode-m-Jump Game
55. Jump GameGiven原创 2016-10-18 21:19:52 · 448 阅读 · 0 评论 -
leetcode-m-Reorder List
143. Reorder List原创 2016-10-18 22:04:31 · 347 阅读 · 0 评论 -
PAT_A 1106. Lowest Price in Supply Chain (25)
1106. Lowest Price in Supply Chain (25)运行超时,采取策略建立备忘录原创 2016-10-06 18:40:44 · 496 阅读 · 0 评论 -
leetcode_easy 344、reverse string
344、reverse string//注意c串的结尾#include<iostream>#include <cstring>#include<string>using namespace std;string reverseString(string s) { int size=s.length(); //必须为c串提供结尾\0空间 char *c=new cha原创 2016-09-05 20:22:40 · 494 阅读 · 0 评论 -
PAT_A 1002 A+B for Polynomials(25)
Pat1002 A+B for Polynomials(25) This time, you are supposed to find A+B where A and B are two polynomials.原创 2016-03-03 09:29:23 · 487 阅读 · 0 评论 -
PAT_A 1110. Complete Binary Tree (25)
题目信息 1110. Complete Binary Tree (25)Given a tree, you are supposed to tell if it is a complete binary tree.Input Specification:Each input file contains one test case. For each case, the first line give原创 2016-03-14 00:05:31 · 846 阅读 · 0 评论 -
PAT_A 1109. Group Photo (25)
pat 1109Group Photo (25)原创 2016-03-13 00:31:50 · 1410 阅读 · 0 评论 -
PAT_A 1108. Finding Average (20)
1108. Finding Average (20)原创 2016-03-12 21:58:54 · 741 阅读 · 0 评论 -
PAT_A 1005. Spell It Right (20)
PAT A 1105原创 2016-03-08 11:18:39 · 394 阅读 · 0 评论 -
PAT_A 1104 Sum of Number Segments (20)
PAT(A) 1104A. Sum of Number Segments (20)原创 2016-03-08 09:44:47 · 347 阅读 · 0 评论 -
PAT_A 1105. Spiral Matrix (25)
PAT 1105. Spiral Matrix (25)原创 2016-10-06 19:15:28 · 411 阅读 · 0 评论 -
PAT_A 1112. Stucked Keyboard (20)
1112. Stucked Keyboard (20)原创 2016-10-06 19:25:49 · 292 阅读 · 0 评论 -
PAT_A 1113. Integer Set Partition (25)
1113. Integer Set Partition (25)原创 2016-10-06 19:29:28 · 377 阅读 · 0 评论 -
PAT_A 1115. Counting Nodes in a BST (30)
1115. Counting Nodes in a BST (30) 二叉搜索树,计算叶子结点和其父结点的个数和。需要先构建该二叉树。原创 2016-10-06 19:37:01 · 341 阅读 · 0 评论 -
PAT_A 1116. Come on! Let's C (20)
1116. Come on! Let’s C (20)待续原创 2016-10-06 19:40:28 · 622 阅读 · 0 评论 -
PAT_A 1117. Eddington Number(25)
1117. Eddington Number(25)待续原创 2016-10-06 19:42:23 · 862 阅读 · 0 评论 -
PAT_A 1118. Birds in Forest (25)
1118. Birds in Forest (25)查并集原创 2016-10-06 19:53:41 · 477 阅读 · 0 评论 -
PAT_A 1119. Pre- and Post-order Traversals (30)
1119. Pre- and Post-order Traversals (30)考察二叉树的几种遍历方式原创 2016-10-06 19:57:03 · 1108 阅读 · 0 评论 -
PAT_A 1004. Counting Leaves (30)
1004. Counting Leaves (30) 树原创 2016-11-20 15:03:22 · 506 阅读 · 0 评论 -
PAT_A 1003. Emergency (25)
1003. Emergency (25) 图原创 2016-11-20 15:14:25 · 398 阅读 · 0 评论 -
PAT_A、1111. Online Map (30)
1111. Online Map (30)Input our current position and a destination, an online map can recommend several paths. Now your job is to recommend two paths to your user: one is the shortest, and the other is原创 2016-11-20 15:20:41 · 827 阅读 · 0 评论 -
PAT_A 1107. Social Clusters (30)
1107. Social Clusters (30)很明显,这道题是考察并查集,但有点不同的是,反过来了,查的不是,hobby的分组,而是查人数的分组。反过来记录即可。[PAT_A1118那个查并集比较直接,不用在反转以下思维](http://blog.youkuaiyun.com/scylhy/article/details/52745290)原创 2016-10-07 12:14:29 · 669 阅读 · 0 评论 -
PAT_A 1006. Sign In and Sign Out (25)
1006. Sign In and Sign Out (25) scanf("%s %02d:%02d:%02d %02d:%02d:%02d",id,&a,&b,&c,&d,&e,&f);//这方法很好,注意是int*原创 2016-11-20 21:29:11 · 428 阅读 · 0 评论 -
PAT_A 1007. Maximum Subsequence Sum (25)
1007. Maximum Subsequence Sum (25)原创 2016-11-20 21:31:10 · 461 阅读 · 0 评论 -
PAT_A 1008. Elevator (20)
1008. Elevator (20)原创 2016-11-20 21:33:13 · 410 阅读 · 0 评论 -
PAT_A 1009. Product of Polynomials (25)
1009. Product of Polynomials (25)原创 2016-11-20 22:37:45 · 463 阅读 · 0 评论 -
PAT_A 1013. Battle Over Cities (25)
1013. Battle Over Cities (25)It is vitally important to have all the cities connected by highways in a war. If a city is occupied by the enemy, all the highways from/toward that city are closed. We mus原创 2016-12-03 14:04:48 · 404 阅读 · 0 评论 -
PAT_A 1014. Waiting in Line (30)
1014. Waiting in Line (30)Suppose a bank has N windows open for service. There is a yellow line in front of the windows which devides the waiting area into two parts. The rules for the customers to wai原创 2016-12-03 13:50:37 · 517 阅读 · 0 评论 -
PAT_A 1010. Radix (25)
1010. Radix (25)原创 2016-11-27 18:09:07 · 401 阅读 · 0 评论 -
PAT_A 1100. Mars Numbers (20)
1100. Mars Numbers (20)字符串处理 getchar() getline() strtok()原创 2016-11-27 18:18:26 · 506 阅读 · 0 评论 -
PAT_A 1016. Phone Bills (25)
1016. Phone Bills (25) 排序 on-off原创 2017-02-07 17:30:05 · 332 阅读 · 0 评论 -
PAT_A 1018. Public Bike Management (30)
1018. Public Bike Management (30)最短距离DFS ,dijkstra原创 2017-02-08 20:18:28 · 530 阅读 · 0 评论 -
PAT_A 1017. Queueing at Bank (25)
1017. Queueing at Bank (25)银行队列模型 8:00-17:00原创 2017-02-07 22:30:31 · 343 阅读 · 0 评论 -
PAT_A 1019. General Palindromic Number (20)
1019. General Palindromic Number (20)A number that will be the same when it is written forwards or backwards is known as a Palindromic Number. For example, 1234321 is a palindromic number. All single d原创 2017-02-09 11:40:35 · 415 阅读 · 0 评论 -
PAT_A 1020. Tree Traversals (25)
PAT_A 1020. Tree Traversals (25)Suppose that all the keys in a binary tree are distinct positive integers. Given the postorder and inorder traversal sequences, you are supposed to output the level orde原创 2017-02-10 12:26:28 · 410 阅读 · 0 评论