自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(160)
  • 收藏
  • 关注

原创 PAT A1021 Deepest Root (25 分)

题目A graph which is connected and acyclic can be considered a tree. The height of the tree depends on the selected root. Now you are supposed to find the root that results in a highest tree. Such a r...

2019-08-25 23:50:21 182

原创 PAT 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 must know immediately if ...

2019-08-23 23:27:37 155

原创 PAT A1107 Social Clusters (30 分)

题目: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. A social cluster is a set of people who have some of...

2019-08-03 23:09:28 189

原创 PAT A1066 Root of AVL Tree (25 分)

题目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, rebalanci...

2019-07-31 19:56:20 155

原创 LeetCode 450. 删除二叉搜索树中的节点

题目:给定一个二叉搜索树的根节点 root 和一个值 key,删除二叉搜索树中的 key 对应的节点,并保证二叉搜索树的性质不变。返回二叉搜索树(有可能被更新)的根节点的引用。一般来说,删除节点可分为两个步骤:首先找到需要删除的节点;如果找到了,删除它。说明: 要求算法时间复杂度为 O(h),h 为树的高度。root = [5,3,6,2,4,null,7]key = 3 ...

2019-07-29 20:59:40 148

原创 PAT1099 Build A Binary Search Tree (30 分)

题目A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties:The left subtree of a node contains only nodes with keys less than the node’s key.The right...

2019-07-28 23:49:12 113

原创 PAT 1064 Complete Binary Search Tree (30 分)

题目:A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties:The left subtree of a node contains only nodes with keys less than the node’s key.The righ...

2019-07-28 00:09:46 129

原创 PAT A1043 Is It a Binary Search Tree (25 分)

题目:A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties:The left subtree of a node contains only nodes with keys less than the node’s key.The righ...

2019-07-26 19:24:55 345

原创 PAT A1004 Counting Leaves (30 分)

题目:A family hierarchy is usually presented by a pedigree tree. Your job is to count those family members who have no child.Input Specification:Each input file contains one test case. Each case st...

2019-07-25 23:19:11 110

原创 PAT A1062

题目A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone involved in moving a product from supplier to customer.Starting from one root supplier, everyone o...

2019-07-25 22:03:47 239

原创 PAT A1094 The Largest Generation (25 分)

题目A family hierarchy is usually presented by a pedigree tree where all the nodes on the same level belong to the same generation. Your task is to find the generation with the largest population.Inp...

2019-07-25 21:40:25 117

原创 PAT 1090 Highest Price in Supply Chain (25 分)

题目:A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone involved in moving a product from supplier to customer.Starting from one root supplier, everyone ...

2019-07-24 23:32:41 128

原创 PAT A1079 Total Sales of Supply Chain (25 分)

题目:A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone involved in moving a product from supplier to customer.Starting from one root supplier, everyone ...

2019-07-23 23:29:52 130

原创 PAT 1103 Integer Factorization

题目:The K−P factorization of a positive integer N is to write N as the sum of the P-th power of K positive integers. You are supposed to write a program to find the K−P factorization of N for any pos...

2019-07-04 20:53:44 158

原创 PAT A1051

题目Given a stack which can keep M numbers at most. Push N numbers in the order of 1, 2, 3, …, N and pop randomly. You are supposed to tell if a given sequence of numbers is a possible pop sequence of...

2019-04-29 12:13:31 164

原创 PAT A1022

题目:A Digital Library contains millions of books, stored according to their titles, authors, key words of their abstracts, publishers, and published years. Each book is assigned an unique 7-digit num...

2019-04-28 20:12:02 215

原创 PAT A1071

题目:People often have a preference among synonyms of the same word. For example, some may prefer “the police”, while others may prefer “the cops”. Analyzing such patterns can help to narrow down a sp...

2019-04-26 18:58:34 193

原创 PAT A1054

题目:Behind the scenes in the computer’s memory, color is always talked about as a series of 24 bits of information for each pixel. In an image, the color with the largest proportional area is called ...

2019-04-22 18:46:39 122

原创 PAT A1100

题目:People on Mars count their numbers with base 13:Zero on Earth is called “tret” on Mars.The numbers 1 to 12 on Earth is called “jan, feb, mar, apr, may, jun, jly, aug, sep, oct, nov, dec” on Ma...

2019-04-22 16:36:32 146

原创 PAT A1060

题目:If a machine can save only 3 significant digits, the float numbers 12300 and 12358.9 are considered equal since they are both saved as 0.123×10​5​​ with simple chopping. Now given the number of s...

2019-04-22 11:34:33 246

原创 PAT A1063

题目:Given two sets of integers, the similarity of the sets is defined to be N​c​​/N​t​​×100%, where N​c​​ is the number of distinct common numbers shared by the two sets, and N​t​​ is the total numbe...

2019-04-21 11:37:22 128

原创 PAT A1047

题目:Zhejiang University has 40,000 students and provides 2,500 courses. Now given the registered course list of each student, you are supposed to output the student name lists of all the courses.Inp...

2019-04-20 16:41:34 284

原创 PAT A1024

题目: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 digit numbers are palindromic nu...

2019-04-19 12:27:04 435

原创 PAT A1023

题目: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 numbe...

2019-04-19 11:11:11 414

原创 PAT A1096

题目:Among all the factors of a positive integer N, there may exist several consecutive numbers. For example, 630 can be factored as 3×5×6×7, where 5, 6, and 7 are the three consecutive numbers. Now g...

2019-04-19 00:50:49 183

原创 PAT A1059

题目:Given any positive integer N, you are supposed to find all of its prime factors, and write them in the format N = p​1​​​k​1​​​​×p​2​​​k​2​​​​×⋯×p​m​​​k​m​​​​.Input Specification:Each input fil...

2019-04-18 16:49:29 188

原创 PAT A1088

题目:For two rational numbers, your task is to implement the basic arithmetics, that is, to calculate their sum, difference, product and quotient.Input Specification:Each input file contains one te...

2019-04-16 11:05:10 124

原创 PAT A1081

题目:Given N rational numbers in the form numerator/denominator, you are supposed to calculate their sum.Input Specification:Each input file contains one test case. Each case starts with a positive...

2019-04-15 16:28:18 205

原创 PAT A1049

题目:The task is simple: given any positive integer N, you are supposed to count the total number of 1’s in the decimal form of the integers from 1 to N. For example, given N being 12, there are five ...

2019-04-12 00:15:36 220

原创 PAT A1010

题目:Given a sequence of positive numbers, a segment is defined to be a consecutive subsequence. For example, given the sequence { 0.1, 0.2, 0.3, 0.4 }, we have 10 segments: (0.1) (0.1, 0.2) (0.1, 0.2...

2019-04-09 14:39:41 181

原创 PAT A1008

题目:The highest building in our city has only one elevator. A request list is made up with N positive numbers. The numbers denote at which floors the elevator will stop, in specified order. It costs ...

2019-04-09 13:57:36 164

原创 PAT A1069

题目:For any 4-digit integer except the ones with all the digits being the same, if we sort the digits in non-increasing order first, and then in non-decreasing order, a new number can be obtained by ...

2019-04-09 11:46:36 275

原创 PAT A1101

题目:There is a classical process named partition in the famous quick sort algorithm. In this process we typically choose one element as the pivot. Then the elements less than the pivot are moved to i...

2019-04-08 17:03:16 169

原创 PAT A1093

题目:The string APPAPT contains two PAT’s as substrings. The first one is formed by the 2nd, the 4th, and the 6th characters, and the second one is formed by the 3rd, the 4th, and the 6th characters....

2019-04-08 13:20:32 93

原创 PAT A1089

题目: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 ...

2019-04-08 11:49:06 213

原创 LeetCode 852

题目:我们把符合下列属性的数组 A 称作山脉:A.length >= 3存在 0 < i < A.length - 1 使得A[0] < A[1] < … A[i-1] < A[i] > A[i+1] > … > A[A.length - 1]给定一个确定为山脉的数组,返回任何满足 A[0] < A[1] < … A...

2019-04-07 23:21:41 138

原创 PAT A1010

题目:Given a pair of positive integers, for example, 6 and 110, can this equation 6 = 110 be true? The answer is yes, if 6 is a decimal number and 110 is a binary number.Now for any pair of positive...

2019-04-07 16:39:52 166

原创 PAT A1029

题目Given an increasing sequence S of N integers, the median is the number at the middle position. For example, the median of S1 = { 11, 12, 13, 14 } is 12, and the median of S2 = { 9, 10, 15, 16, 17 ...

2019-04-07 16:10:58 217

原创 PAT A1044

题目:Shopping in Mars is quite a different experience. The Mars people pay by chained diamonds. Each diamond has a value (in Mars dollars M$). When making the payment, the chain can be cut at any pos...

2019-04-06 13:34:13 369

原创 PAT A1085

题目:Given a sequence of positive integers and another positive integer p. The sequence is said to be a perfect sequence if M≤m×p where M and m are the maximum and minimum numbers in the sequence, res...

2019-04-06 10:55:40 181 1

空空如也

空空如也

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

TA关注的人

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