自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

咸鱼夏の翻身观察记录

吾日三省吾身:敲代码否?敲代码否?敲代码否?

  • 博客(122)
  • 收藏
  • 关注

原创 PAT 1141 PAT Ranking of Institutions [map STL] [sort排序] [string类型的大小写转换]

After each PAT, the PAT Center will announce the ranking of institutions based on their students' performances. Now you are asked to generate the ranklist.Input Specification:Each input file conta...

2019-06-05 20:56:58 382

原创 PAT 1116 Come on! Let's C [逻辑题] [素数判断]

"Let's C" is a popular and fun programming contest hosted by the College of Computer Science and Technology, Zhejiang University. Since the idea of the contest is for fun, the award rules are funny as...

2019-05-21 20:53:37 249

原创 LeetCode [栈] 496.Next Greater Element I(C++和Python实现)

496 Next Greater Element I[难度:简单][哈希表/栈]【题目】You are given two arrays(without duplicates)nums1andnums2wherenums1’s elements are subset ofnums2. Find all the next greater numbers fornums1'...

2019-05-18 14:14:20 247

原创 LeetCode [栈] 682.Baseball Game(C++和Python实现)

682 Baseball Game[难度:简单][stringstream:字符串转整数神器]【题目】You're now a baseball game point recorder.Given a list of strings, each string can be one of the 4 following types:Integer(one round's sco...

2019-05-18 14:14:12 221

原创 LeetCode [栈] 844.Backspace String Compare(C++和Python实现)

844 Backspace String Compare [难度:简单] [空间复杂度为1|巧妙运用变量]【题目】Given twostringsSandT,return if they are equal when both are typed into empty text editors.#means a backspace character.Example 1:...

2019-05-17 19:55:13 387

原创 LeetCode [栈] 155.Min Stack(C++和Python实现)

155 Min Stack [难度:简单] [最小栈] (解法很巧妙)【题目】Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.push(x) -- Push element x onto stack. pop() -- Removes th...

2019-05-17 19:53:25 266

原创 LeetCode [栈] 20.Valid Parentheses (C++和Python实现)

20 Valid Parentheses [难度:简单] [括号匹配]【题目】Given a string containing just the characters'(',')','{','}','['and']', determine if the input string is valid.An input string is valid if:Open br...

2019-05-17 19:51:52 201

原创 LeetCode [链表] 141.Linked List Cycle (C++和Python实现)

141.Linked List Cycle [难度:简单]【题目】Given a linked list, determine if it has a cycle in it.To represent a cycle in the given linked list, we use an integerposwhich represents the position (0-inde...

2019-05-17 19:49:52 198

原创 LeetCode [链表] 234.Palindrome Linked List (C++和Python实现)

234.Palindrome Linked List [难度:简单]【题目】Given a singly linked list, determine if it is a palindrome.Example 1:Input: 1->2Output: falseExample 2:Input: 1->2->2->1Output: true...

2019-05-17 19:48:22 265

原创 LeetCode [链表] 876. Middle of the Linked List (C++和Python实现)

876. Middle of the Linked List [难度:简单]【题目】Given a non-empty, singlylinked list with head nodehead, returnamiddle node of linked list.If there are two middle nodes, return the second middle n...

2019-05-17 19:46:42 321

原创 LeetCode [链表] 206. Reverse Linked List (C++和Python实现)

206. Reverse Linked List [难度:简单]【题目】Reverse a singly linked list.Example:Input: 1->2->3->4->5->NULLOutput: 5->4->3->2->1->NULLFollow up:A linked list can b...

2019-05-17 19:45:04 193

原创 LeetCode [链表] 19.Remove Nth Node From End of List (C++和Python实现)

19.Remove Nth Node From End of List [难度:中等]【题目】Given a linked list, remove then-th node from the end of list and return its head.Example:Given linked list: 1->2->3->4->5, and n =...

2019-05-17 19:42:41 210

原创 LeetCode [链表] 21.Merge Two Sorted Lists (C++和Python实现)

21.Merge Two Sorted Lists [难度:简单]【题目】Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.Example:Input...

2019-05-17 19:41:11 182

原创 PAT 1132 Cut Integer [string相关操作] [余数为0的浮点错误]

Cutting an integer means to cut a K digits lone integer Z into two integers of (K/2) digits long integers A and B. For example, after cutting Z = 167334, we have A = 167 and B = 334. It is interesting...

2019-05-17 19:33:34 249

原创 PAT 1136 A Delayed Palindrome [字符串反转] [大整数运算]

Consider a positive integerNwritten in standard notation withk+1digitsa​i​​asa​k​​⋯a​1​​a​0​​with0≤a​i​​<10for allianda​k​​>0. ThenNispalindromicif and only ifa​i​​=a​k−i​​for a...

2019-05-16 20:45:03 224

原创 PAT 1140 Look-and-say Sequence [字符串处理] [模拟]

Look-and-say sequence is a sequence of integers as the following:D, D1, D111, D113, D11231, D112213111, ...whereDis in [0, 9] except 1. The (n+1)st number is a kind of description of the nth n...

2019-05-15 20:08:43 221

原创 PAT 1082 Read Number in Chinese [字符串处理] [数字分位读法]

Given an integer with no more than 9 digits, you are supposed to read it in the traditional Chinese way. OutputFufirst if it is negative. For example, -123456789 is read asFu yi Yi er Qian san Bai ...

2019-05-11 20:32:58 337

原创 PAT 1023 Have Fun with Numbers [大整数运算]

Notice that the number 123456789 is a 9-digit number consisting exactly the numbers from 1 to 9, with no duplication. Double it we will obtain 246913578, which happens to be another 9-digit number con...

2019-04-21 20:11:03 189

原创 PAT 1017 Queueing at Bank [模拟]

Suppose a bank hasKwindows open for service. There is a yellow line in front of the windows which devides the waiting area into two parts. All the customers have to wait in line behind the yellow li...

2019-04-12 20:30:25 236

原创 PAT 1105 Spiral Matrix [顺时针打印矩阵] [模拟]

This time your job is to fill a sequence ofNpositive integers into aspiral matrixin non-increasing order. A spiral matrix is filled in from the first element at the upper-left corner, then move in...

2019-04-11 18:55:05 168

原创 PAT 1015 Reversible Primes [素数判断] [数字翻转] [进制转换]

Areversible primein any number system is a prime whose "reverse" in that number system is also a prime. For example in the decimal system 73 is a reversible prime because its reverse 37 is also a pr...

2019-04-10 19:37:09 175

原创 PAT 1087 All Roads Lead to Rome [dijkstra+DFS] [map处理int和string的相互转换]

Indeed there are many different tourist routes from our city to Rome. You are supposed to find your clients the route with the least cost while gaining the most happiness.Input Specification:Each ...

2019-04-09 20:48:54 453

原创 PAT 1072 Gas Station [dijkstra]

A gas station has to be built at such a location that the minimum distance between the station and any of the residential housing is as far away as possible. However it must guarantee that all the hou...

2019-04-06 21:26:18 145

原创 【Python】函数参数总结(位置参数|默认参数|可变参数|关键字参数|命名关键字参数|参数组合)

位置参数(从左至右进行匹配)是最普遍最常见的类型。def posFx(a,b): print("a =",a,"b =",b)posFx(1,2) #a = 1 b = 2posFx(2,1) #a = 2 b = 1默认参数(默认参数允许创建函数可选的参数)如果没有传入值的话,在函数运行前,参数就被赋予了默认值。def defFx(a,b): pri...

2019-04-06 20:02:21 484

原创 详解200行Python代码实现控制台版2048【总有一款坑适合你】【超详细】

跟着实验楼学习了2048的Python实现,先丢个地址200行Python代码实现2048我接触Python时间不长,只了解一些基本的语法和容器,在学习的过程中遇到不少问题,这里做一个记录。curses库(windows系统)本来想着在搞明白之前先运行代码看看效果,结果光这里的报错就折腾了我好半天。查了下才知道curses库不支持windows系统,需要使用一个 unofficial...

2019-03-30 19:44:45 1489 1

原创 PAT 1018 Public Bike Management [dijkstra+DFS]

There is a public bike service in Hangzhou City which provides great convenience to the tourists from all over the world. One may rent a bike at any station and return it to any other stations in the ...

2019-03-22 18:56:12 202

原创 【Python】空格字符串的处理技巧 | sep和end | 没有自增符的原因 | 格式化输出

空格字符串的处理技巧①lstrip() 用于截掉字符串左边的空格或指定字符。 返回截掉字符串左边的空格或指定字符后生成的新字符串。 * 匹配时不是按照整个字符串匹配的,而是一个一个进行匹配。但是如果混有str = 'abcdabcdPYTHON'print(str.lstrip('dcba'))#PYTHONstr = ' PYTHON'print(...

2019-03-18 16:38:45 3074

原创 PAT 1030 Travel Plan [dijkstra+DFS] [最短路径输出]

A traveler's map gives the distances between cities along the highways, together with the cost of each highway. Now you are supposed to write a program to help a traveler to decide the shortest path b...

2019-03-15 19:52:59 198

原创 PAT 1003 Emergency [dijkstra] [最短路径条数]

As an emergency rescue team leader of a city, you are given a special map of your country. The map shows several scattered cities connected by some roads. Amount of rescue teams in each city and the l...

2019-03-08 19:44:53 178

原创 【总结】2019春季甲级PAT考试的心路历程(炮灰经历)

寒假开始准备PAT,看的晴神宝典,考前大略过了百分之八十,还剩图和后面的内容没来得及看。题库刷了84道,每道题都发了博客记录,其中有一半都是参考别人的思路,还经常有不能理解题目意思的时候。综上,考前我就有预感,这是一次炮灰经历了。前几天抱佛脚复习时开始回顾发过的博客,发现记录真是一件美妙的事情,它让成长的轨迹实现了真正意义上的有迹可循。所以这次再炮灰也决定记录下来,以便作为未来的笑料以及现...

2019-03-03 12:02:12 2851 1

原创 PAT 1013 Battle Over Cities [图的遍历] [连通块的个数] [DFS]

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 must know immediately if we nee...

2019-02-25 19:29:25 187

原创 PAT 1034 Head of a Gang [图的遍历] [DFS] [map处理string和int的互相转化]

One way that the police finds the head of a gang is to check people's phone calls. If there is a phone call betweenAandB, we say thatAandBis related. The weight of a relation is defined to be t...

2019-02-25 17:14:55 176

原创 PAT 1076 Forwards on Weibo [图的遍历] [BFS] [邻接表/邻接矩阵]

Weibo is known as the Chinese version of Twitter. One user on Weibo may have many followers, and may follow many other users as well. Hence a social network is formed with followers relations. When a ...

2019-02-25 15:45:54 188

原创 PAT 1147 Heaps

In computer science, a heap is a specialized tree-based data structure that satisfies the heap property: if P is a parent node of C, then the key (the value) of P is either greater than or equal to (i...

2019-02-24 14:20:55 199

原创 PAT 1098 Insertion or Heap Sort

According to Wikipedia:Insertion sort iterates, consuming one input element each repetition, and growing a sorted output list. Each iteration, insertion sort removes one element from the input data,...

2019-02-24 13:42:30 136

原创 PAT 1089 Insert or Merge

According to Wikipedia:Insertion sort iterates, consuming one input element each repetition, and growing a sorted output list. Each iteration, insertion sort removes one element from the input data,...

2019-02-22 16:47:40 148

原创 【堆】建堆 | 删除栈顶元素 | 添加元素 | 堆排序

堆的定义堆是一棵完全二叉树,树中每个结点的值都不小于(或不大于)其左右孩子结点的值。如果父亲结点大于或等于孩子结点的值,那么称这样的堆为最大堆。反之,最小堆。以下都以最大堆作为实例。int heap[100]; 建堆建堆的过程是不断调整的过程,每次调整都是把结点从上往下的调整(父结点和子结点的交换),即向下调整。调整方法是这样的:总是将当前结点V与它的左右孩子比较(如果有...

2019-02-21 17:54:20 1247

原创 PAT 1007 Maximum Subsequence Sum [在线处理]

Given a sequence ofKintegers {N​1​​,N​2​​, ...,N​K​​}. A continuous subsequence is defined to be {N​i​​,N​i+1​​, ...,N​j​​} where1≤i≤j≤K. The Maximum Subsequence is the continuous subsequen...

2019-02-21 11:48:08 150

原创 PAT 1107 Social Clusters [并查集]

When register on a social network, you are always asked to specify your hobbies in order to find some potential friends with the same hobbies. Asocial clusteris a set of people who have some of thei...

2019-02-20 14:50:44 146

原创 PAT 1066 Root of AVL Tree

An AVL tree is a self-balancing binary search tree. In an AVL tree, the heights of the two child subtrees of any node differ by at most one; if at any time they differ by more than one, rebalancing is...

2019-02-19 17:28:57 204

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除