03 2020 档案
摘要:The magic shop in Mars is offering some magic coupons. Each coupon has an integer N printed on it, meaning that when you use this coupon with a produc
阅读全文
摘要:With highways available, driving a car from Hangzhou to any other city is easy. But since the tank capacity of a car is limited, we have to find gas s
阅读全文
摘要: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 r
阅读全文
摘要:非线性时间比较类 1. 交换排序 1.冒泡排序 思想:从前往后扫描,如果相邻两个元素的大小不满足要求,则进行交换。因此,每一轮可以将最大的元素放到最后一位,下一轮扫描时,就无需进行到最后一位了。 时间复杂度:进行两重循环,因此是O(n^2) 空间复杂度:原地排序,无需其他额外的空间,因此是O(1)
阅读全文
摘要: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 progra
阅读全文
摘要: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 1
阅读全文
摘要:include include include include include include include include include include include include include using namespace std; struct node{ string id, n
阅读全文
摘要:题意 给出一个区间的集合,请合并所有重叠的区间。 示例 输入: [[1,3],[2,6],[8,10],[15,18]] 输出: [[1,6],[8,10],[15,18]] 解释: 区间 [1,3] 和 [2,6] 重叠, 将它们合并为 [1,6]. 思路 贪心,按照每个区间的开始值,从小到大排序
阅读全文
摘要:Programming Ability Test (PAT) is organized by the College of Computer Science and Technology of Zhejiang University. Each test is supposed to run sim
阅读全文
摘要: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 numbe
阅读全文
摘要: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
阅读全文
摘要: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 2469135
阅读全文
摘要:Suppose that all the keys in a binary tree are distinct positive integers. Given the postorder and inorder traversal sequences, you are supposed to ou
阅读全文
摘要: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 .
阅读全文