![](https://img-blog.csdnimg.cn/20201014180756916.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
刷题之路
qq2215459786
这个作者很懒,什么都没留下…
展开
-
Day59: [PAT甲级] 1083 List Grades (25分)
Day59: [PAT甲级] 1083 List Grades (25分)题源:来自PAT真题库:https://pintia.cn/problem-sets/994805342720868352/problems/994805383929905152代码:dirty code凑合看吧#include<iostream>#include<string>#i...原创 2020-01-28 20:34:32 · 173 阅读 · 0 评论 -
Day58: [PAT甲级] 1029 Median (25分)
Day58: [PAT甲级] 1029 Median (25分)题源:来自PAT真题库:https://pintia.cn/problem-sets/994805342720868352/problems/994805466364755968代码:dirty code凑合看吧#include<iostream>#include<string>#includ...原创 2020-01-28 17:41:08 · 137 阅读 · 0 评论 -
Day57: [PAT甲级] 1030 Travel Plan (30分)
Day57: [PAT甲级] 1030 Travel Plan (30分)(双权Dij)题源:来自PAT真题库:https://pintia.cn/problem-sets/994805342720868352/problems/994805464397627392代码:dirty code凑合看吧#include<iostream>#include<string...原创 2020-01-27 22:38:45 · 1617 阅读 · 0 评论 -
Day56: [PAT甲级] 1035 Password (20分)
Day56: [PAT甲级] 1035 Password (20分)题源:来自PAT真题库:https://pintia.cn/problem-sets/994805342720868352/problems/994805454989803520代码:dirty code凑合看吧#include<iostream>#include<string>#incl...原创 2020-01-25 22:48:30 · 115 阅读 · 0 评论 -
Day55: [PAT甲级] 1036 Boys vs Girls (25分)
Day55: [PAT甲级] 1036 Boys vs Girls (25分)题源:来自PAT真题库:https://pintia.cn/problem-sets/994805342720868352/problems/994805453203030016代码:dirty code凑合看吧#include<iostream>#include<string>...原创 2020-01-25 22:46:20 · 93 阅读 · 0 评论 -
Day54: [PAT甲级] 1037 Magic Coupon (25分)
Day54: [PAT甲级] 1037 Magic Coupon (25分)题源:来自PAT真题库:https://pintia.cn/problem-sets/994805342720868352/problems/994805451374313472代码:dirty code凑合看吧#include<iostream>#include<string>#...原创 2020-01-25 22:44:08 · 100 阅读 · 0 评论 -
Day53: [PAT甲级] 1010 Radix (25分)
Day53: [PAT甲级] 1010 Radix (25分)题源:来自PAT真题库:https://pintia.cn/problem-sets/994805342720868352/problems/994805507225665536代码:dirty code凑合看吧#include<iostream>#include<string>#include...原创 2020-01-23 22:53:51 · 99 阅读 · 0 评论 -
Day52: [PAT甲级] 1019 General Palindromic Number (20分)
Day52: [PAT甲级] 1019 General Palindromic Number (20分)题源:来自PAT真题库:https://pintia.cn/problem-sets/994805342720868352/problems/994805487143337984代码:dirty code凑合看吧#include<iostream>#include&l...原创 2020-01-23 20:17:53 · 154 阅读 · 0 评论 -
Day51: [PAT甲级] 1014 Waiting in Line (30分)
Day51: [PAT甲级] 1014 Waiting in Line (30分)题源:来自PAT真题库:https://pintia.cn/problem-sets/994805342720868352/problems/994805498207911936代码:dirty code凑合看吧#include<iostream>#include<string>...原创 2020-01-22 21:50:50 · 95 阅读 · 0 评论 -
Day50: [PAT甲级] 1025 PAT Ranking (25分)
Day50: [PAT甲级] 1025 PAT Ranking (25分)题源:来自PAT真题库:https://pintia.cn/problem-sets/994805342720868352/problems/994805474338127872代码:dirty code凑合看吧#include<iostream>#include<string>#i...原创 2020-01-21 21:58:06 · 739 阅读 · 0 评论 -
Day49: [PAT甲级] 1024 Palindromic Number (25分)
Day49: [PAT甲级] 1024 Palindromic Number (25分)题源:来自PAT真题库:https://pintia.cn/problem-sets/994805342720868352/problems/994805476473028608代码:dirty code凑合看吧#include<iostream>#include<string...原创 2020-01-21 00:03:39 · 128 阅读 · 0 评论 -
Day48: [PAT甲级] 1023 Have Fun with Numbers (20分)
Day48: [PAT甲级] 1023 Have Fun with Numbers (20分)题源:来自PAT真题库:https://pintia.cn/problem-sets/994805342720868352/problems/994805478658260992代码:dirty code凑合看吧#include<iostream>#include<str...原创 2020-01-19 22:26:45 · 93 阅读 · 0 评论 -
Day47: [PAT甲级] 1022 Digital Library (30分)
Day47: [PAT甲级] 1022 Digital Library (30分)题源:来自PAT真题库:https://pintia.cn/problem-sets/994805342720868352/problems/994805480801550336代码:dirty code凑合看吧#include<iostream>#include<string>...原创 2020-01-17 22:47:37 · 122 阅读 · 0 评论 -
Day46: [PAT甲级] 1021 Deepest Root (25分)
Day46: [PAT甲级] 1021 Deepest Root (25分)题源:来自PAT真题库:https://pintia.cn/problem-sets/994805342720868352/problems/994805482919673856代码:dirty code凑合看吧#include<iostream>#include<string>#...原创 2020-01-14 17:05:36 · 110 阅读 · 0 评论 -
Day45: [PAT甲级] 1020 Tree Traversals (25分)
Day45: [PAT甲级] 1020 Tree Traversals (25分)题源:来自PAT甲级题库:https://pintia.cn/problem-sets/994805342720868352/problems/994805485033603072代码:dirty code凑合看吧思路就是通过前序遍历和中序遍历直接把树构造好,然后层序遍历。#include<io...原创 2020-01-12 23:30:26 · 99 阅读 · 0 评论 -
Day44: [PAT甲级] 1017 Queueing at Bank (25分)
Day44: [PAT甲级] 1017 Queueing at Bank (25分)题源:来自PAT甲级题库:https://pintia.cn/problem-sets/994805342720868352/problems/994805491530579968代码:dirty code凑合看吧#include<iostream>#include<string&...原创 2020-01-12 17:43:29 · 129 阅读 · 0 评论 -
Day43: [PAT甲级] 1016 Phone Bills (25分)
Day43: [PAT甲级] 1016 Phone Bills (25分)题源:来自PAT甲级题库:https://pintia.cn/problem-sets/994805342720868352/problems/994805493648703488代码:dirty code凑合看吧因为把单词total写成了toltal,导致我折腾了一个小时不知道哪里错(笑哭)#include...原创 2020-01-11 14:21:39 · 142 阅读 · 0 评论 -
Day42: [PAT甲级] 1015 Reversible Primes (20分)
Day42: [PAT甲级] 1015 Reversible Primes (20分)题源:来自PAT甲级题库:https://pintia.cn/problem-sets/994805342720868352/problems/994805495863296000代码:dirty code凑合看吧三种函数要熟练:其他进制转10进制;10进制转其他进制;判断素数#include&l...原创 2020-01-09 19:35:53 · 96 阅读 · 0 评论 -
Day41: [PAT甲级] 1013 Battle Over Cities (25分)
Day41: [PAT甲级] 1013 Battle Over Cities (25分)题源:来自PAT真题库:https://pintia.cn/problem-sets/994805342720868352/problems/994805500414115840代码:dirty code凑合看吧ps.还有一种并查集的思路。但是要注意路径压缩!pps.这道题我最先用邻接矩阵+BF...原创 2020-01-04 16:50:16 · 88 阅读 · 0 评论 -
Day39: [蓝桥杯真题] 合根植物
Day39: [蓝桥杯真题] 合根植物题源:来自蓝桥杯题库:http://lx.lanqiao.cn/problemsets.page代码:dirty code凑合看吧#include<iostream>#include<string>#include<algorithm>#include<vector>using namesp...原创 2020-01-01 16:50:52 · 105 阅读 · 0 评论 -
Day38: [LeetCode中等] 114. 二叉树展开为链表
Day38: [LeetCode中等] 114. 二叉树展开为链表题源:来自leetcode题库:https://leetcode-cn.com/problems/flatten-binary-tree-to-linked-list/代码:dirty code凑合看吧/** * Definition for a binary tree node. * struct TreeNode...原创 2019-12-29 21:56:49 · 115 阅读 · 0 评论 -
Day38: [蓝桥杯真题] 小计算器
Day38: [蓝桥杯真题] 小计算器题源:来自蓝桥杯题库:http://lx.lanqiao.cn/problemsets.page代码:dirty code凑合看吧#include<iostream>#include<string>#include<algorithm>#include<functional>using na...原创 2019-12-24 21:20:32 · 181 阅读 · 0 评论 -
Day37_ [LeetCode简单] 113. 路径总和 II
Day37: [LeetCode简单] 113. 路径总和 II题源:来自leetcode题库:https://leetcode-cn.com/problems/path-sum-ii/代码:dirty code凑合看吧/** * Definition for a binary tree node. * struct TreeNode { * int val; * ...原创 2019-12-22 21:26:20 · 123 阅读 · 0 评论 -
Day36: [LeetCode简单] 112. 路径总和
Day36: [LeetCode简单] 112. 路径总和题源:来自leetcode题库:https://leetcode-cn.com/problems/path-sum/代码:dirty code凑合看吧/** * Definition for a binary tree node. * struct TreeNode { * int val; * Tree...原创 2019-12-20 21:41:36 · 136 阅读 · 0 评论 -
Day35: [LeetCode简单] 108. 将有序数组转换为二叉搜索树
Day35: [LeetCode简单] 108. 将有序数组转换为二叉搜索树题源:来自leetcode题库:https://leetcode-cn.com/problems/convert-sorted-array-to-binary-search-tree/代码:dirty code凑合看吧/** * Definition for a binary tree node. * st...原创 2019-12-17 22:48:21 · 98 阅读 · 0 评论 -
Day34: [LeetCode简单] 110. 平衡二叉树
Day34: [LeetCode简单] 110. 平衡二叉树题源:来自leetcode题库:https://leetcode-cn.com/problems/balanced-binary-tree/代码:dirty code凑合看吧/** * Definition for a binary tree node. * struct TreeNode { * int val...原创 2019-12-17 22:45:00 · 93 阅读 · 0 评论 -
Day33: [LeetCode中等] 106. 从中序与后序遍历序列构造二叉树
Day33: [LeetCode中等] 106. 从中序与后序遍历序列构造二叉树题源:来自leetcode题库:https://leetcode-cn.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal/代码:dirty code凑合看吧/** * Definition for a binary...原创 2019-12-16 21:53:07 · 80 阅读 · 0 评论 -
Day32: [LeetCode中等] 105. 从前序与中序遍历序列构造二叉树
Day32: [LeetCode中等] 105. 从前序与中序遍历序列构造二叉树题源:来自leetcode题库:https://leetcode-cn.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal/代码:dirty code凑合看吧/** * Definition for a binary...原创 2019-12-16 21:52:45 · 79 阅读 · 0 评论 -
Day31: [LeetCode简单] 101. 对称二叉树
Day31: [LeetCode简单] 101. 对称二叉树题源:来自leetcode题库:https://leetcode-cn.com/problems/symmetric-tree/代码:dirty code凑合看吧/** * Definition for a binary tree node. * struct TreeNode { * int val; * ...原创 2019-12-16 21:52:32 · 93 阅读 · 0 评论 -
Day30: [LeetCode中等] 98. 验证二叉搜索树
Day30: [LeetCode中等] 98. 验证二叉搜索树题源:来自leetcode题库:https://leetcode-cn.com/problems/validate-binary-search-tree/代码:dirty code凑合看吧/** * Definition for a binary tree node. * struct TreeNode { * ...原创 2019-12-12 16:43:26 · 85 阅读 · 0 评论 -
Day29: [LeetCode中等] 96. 不同的二叉搜索树
Day29: [LeetCode中等] 96. 不同的二叉搜索树题源:来自leetcode题库:https://leetcode-cn.com/problems/unique-binary-search-trees/代码:dirty code凑合看吧class Solution {public: int a[9999999]={0}; int f(int n){ ...原创 2019-12-11 21:50:29 · 73 阅读 · 0 评论 -
Day28: [LeetCode中等] 1171. 从链表中删去总和值为零的连续节点
Day28: [LeetCode中等] 1171. 从链表中删去总和值为零的连续节点题源:来自leetcode题库:https://leetcode-cn.com/problems/remove-zero-sum-consecutive-nodes-from-linked-list/思路:遍历链表,算出前置和,依次放进set里,然后遇到相同的的话,就会知道,这两个相同的前置和之间的值的总...原创 2019-12-09 20:38:34 · 213 阅读 · 0 评论 -
Day27: [LeetCode中等] 3. 无重复字符的最长子串
Day27: [LeetCode中等] 3. 无重复字符的最长子串题源:来自leetcode题库:https://leetcode-cn.com/problems/longest-substring-without-repeating-characters/### 思路:这题我用的方法有点小笨,首先设置左右下标,分别指向最长无重复字串的两端,遍历字符串,依次放进set里,然后遇到相同的就...原创 2019-12-09 20:38:16 · 91 阅读 · 0 评论 -
Day26: [LeetCode中等] 725. 分隔链表
Day26: [LeetCode中等] 725. 分隔链表题源:来自leetcode题库:https://leetcode-cn.com/problems/split-linked-list-in-parts/思路:这道题代码很简单,思路上需要注意的是:怎么确定当前要分的vector的长度。如果你要是简单的用除法就会出问题,比如8个值分为三份,应该分为3,3,2。但是8/3=2,加上余...原创 2019-12-07 21:09:05 · 121 阅读 · 0 评论 -
Day25: [LeetCode中等] 817. 链表组件
Day25: [LeetCode中等] 817. 链表组件题源:来自leetcode题库:https://leetcode-cn.com/problems/linked-list-components/思路:就是先把vector里的整数都放在set里,然后遍历链表,一旦有组件中的值,就计数加一,然后把组件邻近值越过。代码:dirty code凑合看吧/** * Definiti...原创 2019-12-07 21:08:47 · 117 阅读 · 0 评论 -
Day24: [LeetCode中等] 1019. 链表中的下一个更大节点
Day24: [LeetCode中等] 1019. 链表中的下一个更大节点题源:来自leetcode题库:https://leetcode-cn.com/problems/next-greater-node-in-linked-list/思路:我是先把链表转存在数组中,然后逆序遍历,用数组xiabiao来储存下一个更大值的数组下标,若没有就是-1。逆序遍历的时候,比较和下一个的值的大小...原创 2019-12-07 21:08:25 · 65 阅读 · 0 评论 -
Day23: [LeetCode中等] 36. 有效的数独
Day23: [LeetCode中等] 36. 有效的数独题源:来自leetcode题库:https://leetcode-cn.com/problems/valid-sudoku/思路:我刚开始看到这题目的想法是:遍历三次二维数组,然后对应三个条件。但是后来发现遍历一次就可以了(其实和遍历三次的时间复杂度是一样的,毕竟是加性的嘛,但是效率肯定高很多),遍历的同时,把值记录在三个二维数...原创 2019-12-04 17:45:34 · 84 阅读 · 0 评论 -
Day22: [LeetCode中等] 31.下一个排列
Day22: [LeetCode中等] 31.下一个排列题源:来自leetcode题库:https://leetcode-cn.com/problems/next-permutation/思路:很有意思的一道题,代码简单,难的是思维的过程。想知道的去看题解吧,懒得说了(哈哈,我这博客好随意)。代码:dirty code凑合看吧class Solution {public: ...原创 2019-12-04 17:45:10 · 71 阅读 · 0 评论 -
Day21: [LeetCode中等] 430. 扁平化多级双向链表
Day21: [LeetCode中等] 430. 扁平化多级双向链表题源:来自leetcode题库:https://leetcode-cn.com/problems/flatten-a-multilevel-doubly-linked-list/思路:我用的是递归的思想,这道题很适合递归。代码:dirty code凑合看吧/*// Definition for a Node....原创 2019-12-04 17:44:02 · 71 阅读 · 0 评论 -
Day19: [LeetCode中等] 328. 奇偶链表
Day20: [LeetCode中等] 328. 奇偶链表题源:来自leetcode题库:https://leetcode-cn.com/problems/odd-even-linked-list/思路:就是间隔性的把链表拆成两个,然后合并一下。代码:dirty code凑合看吧/** * Definition for singly-linked list. * struct...原创 2019-11-30 21:11:22 · 118 阅读 · 0 评论