06 2016 档案

摘要:一、题目描述输入一个矩阵,按照从外向里以顺时针的顺序依次打印出每一个数字,例如,如果输入如下矩阵: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 则依次打印出数字1,2,3,4,8,12,16,15,14,13,9,5,6,7,11,10.二、输入描... 阅读全文
posted @ 2016-06-30 00:36 chenximcm 阅读(217) 评论(0) 推荐(0)
摘要:一、题目描述操作给定的二叉树,将其变换为源二叉树的镜像。二、输入描述二叉树的镜像定义:源二叉树 8 / \ 6 10 / \ / \ 5 7 9 11三、输出描述镜像二叉... 阅读全文
posted @ 2016-06-30 00:07 chenximcm 阅读(118) 评论(0) 推荐(0)
摘要:一、题目描述输入两颗二叉树A,B,判断B是不是A的子结构。二、输入描述输入两棵树A,B。三、输出描述判断B是不是A的子结构,是返回true,否则返回false。四、牛客网提供的框架/*struct TreeNode { int val; struct TreeNode ... 阅读全文
posted @ 2016-06-29 23:39 chenximcm 阅读(170) 评论(0) 推荐(0)
摘要:一、题目描述输入两个单调递增的链表,输出两个链表合成后的链表,当然我们需要合成后的链表满足单调不减规则。二、输入描述两个递增排序的链表三、输出描述合并成一个递增排序的链表四、牛客网提供的框架/*struct ListNode { int val; struct List... 阅读全文
posted @ 2016-06-29 16:30 chenximcm 阅读(138) 评论(0) 推荐(0)
摘要:一、题目描述输入一个链表,反转链表后,输出链表的所有元素。二、输入描述输入一个链表三、输出描述返回逆转后的链表四、牛客网提供的框架/*struct ListNode { int val; struct ListNode *next; ListNode(int x)... 阅读全文
posted @ 2016-06-29 14:20 chenximcm 阅读(186) 评论(0) 推荐(0)
摘要:一、题目描述输入一个链表,输出该链表中倒数第k个结点。二、输入描述一个链表三、输出描述链表的倒数第k个结点四、牛客网提供的框架/*struct ListNode { int val; struct ListNode *next; ListNode(int x) :... 阅读全文
posted @ 2016-06-29 13:33 chenximcm 阅读(134) 评论(0) 推荐(0)
摘要:一、题目描述输入一个整数数组,实现一个函数来调整该数组中数字的顺序,使得所有的奇数位于数组的前半部分,所有的偶数位于位于数组的后半部分,并保证奇数和奇数,偶数和偶数之间的相对位置不变。二、输入描述输入一个数组三、输出描述输出处理后的数组(所有的偶数位于位于数组的后半部分,并保证奇数... 阅读全文
posted @ 2016-06-29 11:30 chenximcm 阅读(117) 评论(0) 推荐(0)
摘要:一、题目描述给定一个double类型的浮点数base和int类型的整数exponent。求base的exponent次方。二、输入double base, int exponent三、输出base的exponent次方的值四、牛客网提供的框架class Solution {publ... 阅读全文
posted @ 2016-06-28 15:13 chenximcm 阅读(136) 评论(0) 推荐(0)
摘要:一、题目描述输入一个整数,输出该数二进制表示中1的个数。其中负数用补码表示。二、牛客网提供的框架class Solution {public: int NumberOf1(int n) { }};三、代码class Solution {public: in... 阅读全文
posted @ 2016-06-28 15:06 chenximcm 阅读(95) 评论(0) 推荐(0)
摘要:一、题目描述我们可以用2*1的小矩形横着或者竖着去覆盖更大的矩形。请问用n个2*1的小矩形无重叠地覆盖一个2*n的大矩形,总共有多少种方法?二、输入描述输入n三、输出描述输出有多少种不同的覆盖方法四、牛客网提供的框架class Solution {public: int re... 阅读全文
posted @ 2016-06-28 15:02 chenximcm 阅读(122) 评论(0) 推荐(0)
摘要:一、题目描述一只青蛙一次可以跳上1级台阶,也可以跳上2级……它也可以跳上n级。求该青蛙跳上一个n级的台阶总共有多少种跳法。二、输入描述n级台阶三、输出描述一共有多少种不同的跳法四、牛客网提供的框架class Solution {public: int jumpFloorII(... 阅读全文
posted @ 2016-06-28 14:57 chenximcm 阅读(140) 评论(0) 推荐(0)
摘要:一、题目描述一只青蛙一次可以跳上1级台阶,也可以跳上2级。求该青蛙跳上一个n级的台阶总共有多少种跳法。二、输入描述输入n级台阶三、输出描述输出总有多少种不同跳法四、牛客网提供的框架class Solution {public: int jumpFloor(int number... 阅读全文
posted @ 2016-06-28 14:46 chenximcm 阅读(138) 评论(0) 推荐(0)
摘要:一、题目描述把一个数组最开始的若干个元素搬到数组的末尾,我们称之为数组的旋转。二、输入描述输入一个递增排序的数组的一个旋转三、输出描述输出旋转数组的最小元素例如: 例如数组{3,4,5,1,2}为{1,2,3,4,5}的一个旋转,该数组的最小值为1。注意:给出的所有元素都大于0,若... 阅读全文
posted @ 2016-06-28 14:39 chenximcm 阅读(145) 评论(0) 推荐(0)
摘要:一、题目描述用两个栈来实现一个队列,完成队列的Push和Pop操作。 队列中的元素为int类型。二、输入描述三、输出描述四、牛客网提供的框架class Solution{public: void push(int node) { } int pop() { ... 阅读全文
posted @ 2016-06-28 14:27 chenximcm 阅读(131) 评论(0) 推荐(0)
摘要:一、题目描述There is a permutation P with n integers from 1 to n. You have to calculate its inversion number, which is the number of pairs of Pi an... 阅读全文
posted @ 2016-06-16 17:03 chenximcm 阅读(228) 评论(0) 推荐(0)
摘要:一、题目描述A thief has robbed a bank in city 1 and he wants to go to city N. The police know that the thief will choose the shortest path to get t... 阅读全文
posted @ 2016-06-16 13:23 chenximcm 阅读(155) 评论(0) 推荐(0)
摘要:一、题目描述Let us define a regular brackets sequence in the following way:Empty sequence is a regular sequence.If S is a regular sequence, then (S... 阅读全文
posted @ 2016-06-16 10:02 chenximcm 阅读(220) 评论(0) 推荐(0)
摘要:一、题目描述Given a sequence A = , let sequence B = be a subsequence of A if there exists a strictly increasing sequence ( i1 is a subsequence of... 阅读全文
posted @ 2016-06-16 09:51 chenximcm 阅读(166) 评论(0) 推荐(0)
摘要:一、题目描述Given a polynomial and the value of the variable x, you task is to calculate the value of the polynomial.二、输入The first line of the inpu... 阅读全文
posted @ 2016-06-16 00:10 chenximcm 阅读(231) 评论(0) 推荐(0)
摘要:一、题目描述One day, WXYZ got a wooden stick, he wanted to split it into three sticks and make a right-angled triangle. You will be given the lengt... 阅读全文
posted @ 2016-06-15 23:42 chenximcm 阅读(167) 评论(0) 推荐(0)
摘要:一、题目描述假设一个字符串只由字符‘0’,‘1’,‘?’组成,其中字符‘?’表示该字符可由字符‘0’或‘1’替代。现有一些字符串,根据这些字符串生成所有可生成的字符串。如:{10,?1,0? }可生成{10,01,11,00}{101,001,?01}可生成{101,001}注意后... 阅读全文
posted @ 2016-06-15 23:21 chenximcm 阅读(458) 评论(0) 推荐(0)
摘要:一、题目描述有红黄蓝3种颜色的n个珠子,师傅希望悟空把它们排成红色珠子在左,黄色珠子居中,蓝色珠子在右的一行,然后告诉师傅,从左数起,第m个珠子是什么颜色。众所周知,悟空是只猴子,他没有这个耐心,你帮帮他吧。二、输入输入第一行为一个整数t(0三、输出为每个测试用例单独一行输出指定的... 阅读全文
posted @ 2016-06-13 23:21 chenximcm 阅读(171) 评论(0) 推荐(0)
摘要:一、题目描述A common divisor for two positive numbers is a number which both numbers are divisible by. It’s easy to calculate the greatest common d... 阅读全文
posted @ 2016-06-13 23:13 chenximcm 阅读(183) 评论(0) 推荐(0)
摘要:一、题目描述The number 151 is a prime palindrome because it is both a prime number and a palindrome (it is the same number when read forward as bac... 阅读全文
posted @ 2016-06-13 22:52 chenximcm 阅读(220) 评论(0) 推荐(0)
摘要:一、题目描述Two players, Singa and Suny, play, starting with two natural numbers. Singa, the first player, subtracts any positive multiple of the l... 阅读全文
posted @ 2016-06-10 10:50 chenximcm 阅读(413) 评论(0) 推荐(0)
摘要:一、题目描述The N cities of Estiah are connected by N-1 roads. The roads are built in a way that it’s always possible to travel between any two cit... 阅读全文
posted @ 2016-06-09 23:03 chenximcm 阅读(201) 评论(0) 推荐(0)
摘要:一、题目描述We wish to tile a grid 4 units high and N units long with rectangles (dominoes) 2 units by one unit (in either orientation). For exampl... 阅读全文
posted @ 2016-06-09 16:53 chenximcm 阅读(443) 评论(0) 推荐(0)
摘要:一、题目描述There is a famous railway station in PopPush City. Country there is incredibly hilly. The station was built in last century. Unfortunat... 阅读全文
posted @ 2016-06-09 14:50 chenximcm 阅读(230) 评论(0) 推荐(0)
摘要:一、题目描述给定一个整数,请将该数各个位上数字反转得到一个新数。新数也应满足整数的常见形式,即除非给定的原数为零,否则反转后得到的新数的最高位数字不应为零(参见样例2)。二、输入输入共 1 行,一个整数N。-1,000,000,000 ≤ N≤ 1,000,000,000。三、输出... 阅读全文
posted @ 2016-06-08 00:49 chenximcm 阅读(140) 评论(0) 推荐(0)
摘要:一、题目描述In computer science and information theory, a Huffman code is an optimal prefix code algorithm.In this exercise, please use Huffman cod... 阅读全文
posted @ 2016-06-08 00:33 chenximcm 阅读(129) 评论(0) 推荐(0)
摘要:一、题目描述In the Fibonacci integer sequence, F0 = 0, F1 = 1, and Fn = Fn-1 + Fn-2 for n ≥ 2. For example, the first ten terms of the Fibonacci se... 阅读全文
posted @ 2016-06-08 00:14 chenximcm 阅读(143) 评论(0) 推荐(0)
摘要:一、题目描述In the Fibonacci integer sequence, F0 = 0, F1 = 1, and Fn = Fn-1 + Fn-2 for n ≥ 2. For example, the first ten terms of the Fibonacci se... 阅读全文
posted @ 2016-06-07 23:12 chenximcm 阅读(241) 评论(0) 推荐(0)