
递归
小·幸·运
你的所有努力最后都会回赠予你。
展开
-
LeetCode-617-Merge Two Binary Trees
Given two binary trees and imagine that when you put one of them to cover the other, some nodes of the two trees are overlapped while the others are not. You need to merge them into a new binary tree....原创 2018-05-25 17:17:17 · 133 阅读 · 0 评论 -
PAT甲级A1155 Heap Paths (30 分)
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-03-16 20:51:41 · 290 阅读 · 0 评论 -
PAT甲级A1103 Integer Factorization (30 分)
The K−PK-PK−P factorization of a positive integer NNN is to write NNN as the sum of the PPP-th power of KKK positive integers. You are supposed to write a program to find the K−PK-PK−P factorization o...原创 2019-02-26 14:59:21 · 266 阅读 · 0 评论 -
PAT甲级A1064 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 right su...原创 2019-01-24 22:16:41 · 193 阅读 · 0 评论 -
PAT甲级A1034 Head of a Gang (30)
One way that the police finds the head of a gang is to check people's phone calls. If there is a phone call between A and B, we say that A and B is related. The weight of a relation is defined to be t...原创 2018-08-24 21:17:37 · 168 阅读 · 0 评论 -
PAT甲级A1030 Travel Plan (30)
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...原创 2018-08-18 20:31:46 · 165 阅读 · 0 评论 -
PAT甲级A1020 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 order traversal sequence of the cor...原创 2018-08-07 22:28:58 · 158 阅读 · 0 评论 -
PAT甲级A1018 Public Bike Management (30)
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 ...原创 2018-08-06 22:21:03 · 263 阅读 · 0 评论 -
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 root ...原创 2018-08-09 22:20:38 · 153 阅读 · 0 评论 -
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.InputEach input file contains one test case. Each case starts with a line co...原创 2018-07-19 21:35:21 · 179 阅读 · 0 评论 -
LeetCode--606. Construct String from Binary Tree
You need to construct a string consists of parenthesis and integers from a binary tree with the preorder traversing way.The null node needs to be represented by empty parenthesis pair "()". And you ne...原创 2018-07-07 22:51:24 · 117 阅读 · 0 评论 -
LeetCode--695. Max Area of Island
Given a non-empty 2D array grid of 0's and 1's, an island is a group of 1's (representing land) connected 4-directionally (horizontal or vertical.) You may assume all four edges of the grid are surro...原创 2018-06-06 22:06:05 · 141 阅读 · 0 评论 -
PAT甲级A1138 Postorder Traversal (25 分)
Suppose that all the keys in a binary tree are distinct positive integers. Given the preorder and inorder traversal sequences, you are supposed to output the first number of the postorder traversal se...原创 2019-03-12 20:12:19 · 231 阅读 · 0 评论