摘要: 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 s 阅读全文
posted @ 2020-05-05 00:24 清明道人 阅读(186) 评论(0) 推荐(0) 编辑
摘要: iven 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 阅读全文
posted @ 2020-04-25 01:30 清明道人 阅读(90) 评论(0) 推荐(0) 编辑
摘要: 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 max 阅读全文
posted @ 2020-04-25 00:24 清明道人 阅读(247) 评论(0) 推荐(0) 编辑
摘要: Given any permutation of the numbers {0, 1, 2,..., N−1}, it is easy to sort them in increasing order. But what if Swap(0, *) is the ONLY operation tha 阅读全文
posted @ 2020-04-13 22:41 清明道人 阅读(121) 评论(0) 推荐(0) 编辑
摘要: Excel can sort records according to any column. Now you are supposed to imitate this function. Input Specification: Each input file contains one test 阅读全文
posted @ 2020-03-30 22:14 清明道人 阅读(83) 评论(0) 推荐(0) 编辑
摘要: Programming Ability Test (PAT) is organized by the College of Computer Science and Technology of Zhejiang University. Each test is supposed to run sim 阅读全文
posted @ 2020-03-30 21:32 清明道人 阅读(227) 评论(0) 推荐(0) 编辑
摘要: 给定一个顺序存储的线性表,请设计一个函数删除所有值大于min而且小于max的元素。删除后表中剩余元素保持顺序存储,并且相对位置不能改变。 函数接口定义: List Delete( List L, ElementType minD, ElementType maxD ); 其中List结构定义如下: 阅读全文
posted @ 2020-03-23 15:01 清明道人 阅读(1835) 评论(2) 推荐(0) 编辑
摘要: 给定一个顺序存储的线性表,请设计一个算法查找该线性表中最长的连续递增子序列。例如,(1,9,2,5,7,3,4,6,8,0)中最长的递增子序列为(3,4,6,8)。 输入格式: 输入第1行给出正整数n(≤);第2行给出n个整数,其间以空格分隔。 输出格式: 在一行中输出第一次出现的最长连续递增子序列 阅读全文
posted @ 2020-03-21 21:57 清明道人 阅读(1451) 评论(1) 推荐(0) 编辑
摘要: 有一种存储英文单词的方法,是把单词的所有字母串在一个单链表上。为了节省一点空间,如果有两个单词有同样的后缀,就让它们共享这个后缀。下图给出了单词“loading”和“being”的存储形式。本题要求你找出两个链表的公共后缀。 函数接口定义: PtrToNode Suffix( List L1, Li 阅读全文
posted @ 2020-03-21 21:52 清明道人 阅读(676) 评论(0) 推荐(0) 编辑
摘要: 给定一个最大容量为 M 的堆栈,将 N 个数字按 1, 2, 3, ..., N 的顺序入栈,允许按任何顺序出栈,则哪些数字序列是不可能得到的?例如给定 M=5、N=7,则我们有可能得到{ 1, 2, 3, 4, 5, 6, 7 },但不可能得到{ 3, 2, 1, 7, 5, 6, 4 }。 输入 阅读全文
posted @ 2020-03-18 22:22 清明道人 阅读(1120) 评论(0) 推荐(0) 编辑