- 博客(14)
- 收藏
- 关注
原创 4-9 二叉树的遍历 (25分)
4-9 二叉树的遍历 (25分)本题要求给定二叉树的4种遍历。函数接口定义:void InorderTraversal( BinTree BT );void PreorderTraversal( BinTree BT );void PostorderTraversal( BinTree BT );void LevelorderTraversal( BinTree
2016-07-20 18:11:11 2395
原创 4-1 单链表逆转 (20分)
4-1 单链表逆转 (20分)本题要求实现一个函数,将给定的单链表逆转。函数接口定义:List Reverse( List L );其中List结构定义如下:typedef struct Node *PtrToNode;struct Node { ElementType Data; /* 存储结点数据 */ PtrToNode Nex
2016-07-20 17:23:25 1718 1
原创 下一个较大元素II
现在有一个数组,请找出数组中每个元素的后面比它大的最小的元素,若不存在则为-1。给定一个int数组A及数组的大小n,请返回每个元素所求的值组成的数组。保证A中元素为正整数,且n小于等于1000。测试样例:[11,13,10,5,12,21,3],7[12,21,12,12,21,-1,-1]class NextElement {public:
2016-07-18 23:13:37 458
原创 用两个栈实现队列
题目描述用两个栈来实现一个队列,完成队列的Push和Pop操作。 队列中的元素为int类型。用两个栈实现一个队列:入队:将元素进栈A出队:判断栈B是否为空,如果为空,则将栈A中所有元素pop,并push进栈B,栈B出栈; 如果不为空,栈B直接出栈。用两个队列实现一个栈:入栈:将元素进队列A出栈:判断队列A中元素
2016-07-18 18:14:00 276
原创 包含min函数的栈
题目描述定义栈的数据结构,请在该类型中实现一个能够得到栈最小元素的min函数。class Solution {public: //本题目其实就是不断将最小值压入栈中即可 stackminstack; void push(int value) { if(minstack.empty()) {
2016-07-18 17:41:23 233
原创 栈的压入、弹出序列
题目描述输入两个整数序列,第一个序列表示栈的压入顺序,请判断第二个序列是否为该栈的弹出顺序。假设压入栈的所有数字均不相等。例如序列1,2,3,4,5是某栈的压入顺序,序列4,5,3,2,1是该压栈序列对应的一个弹出序列,但4,3,5,1,2就不可能是该压栈序列的弹出序列。(注意:这两个序列的长度是相等的)class Solution {public: //
2016-07-18 13:47:41 237
原创 evaluate-reverse-polish-notation
题目描述Evaluate the value of an arithmetic expression in Reverse Polish Notation.Valid operators are+,-,*,/. Each operand may be an integer or another expression.Some examples: ["2
2016-07-17 18:03:54 371
原创 longest-valid-parentheses
题目描述Given a string containing just the characters'('and')', find the length of the longest valid (well-formed) parentheses substring.For"(()", the longest valid parentheses substring i
2016-07-17 16:19:18 321
原创 valid-parentheses
题目描述Given a string containing just the characters'(',')','{','}','['and']', determine if the input string is valid.The brackets must close in the correct order,"()"and"()[]{}"are all v
2016-07-17 12:03:47 309
原创 表达式合法判断
表达式合法判断参与人数:453时间限制:3秒空间限制:32768K本题知识点: 栈 算法知识视频讲解题目描述写一段代码,判断一个包括'{','[','(',')',']','}'的表达式是否合法(注意看样例的合法规则。)给定一个表达式A,请返回一个bool值,代表它是否合法。测试样例:"[a+b*(5-4)]*{x+b+b*({1+2
2016-07-16 22:39:10 5211 1
原创 如何实现用递归函数和栈操作逆序栈
用递归函数和栈操作逆序栈参与人数:894时间限制:3秒空间限制:32768K本题知识点: 栈 递归 算法知识视频讲解题目描述一个栈依次压入1,2,3,4,5那么从栈顶到栈底分别为5,4,3,2,1。将这个栈转置后,从栈顶到栈底为1,2,3,4,5,也就是实现了栈中元素的逆序,请设计一个算法实现逆序栈的操作,但是只能用递归函数来实现,而不能用另外的数据
2016-07-16 21:25:52 654
原创 链表的回文结构
返回难题列表讨论排行我的提交链表的回文结构参与人数:797时间限制:3秒空间限制:32768K本题知识点: 栈 链表 算法知识视频讲解题目描述对于一个链表,请设计一个时间复杂度为O(n),额外空间复杂度为O(1)的算法,判断其是否为回文结构。给定一个链表的头指针A,请返回一个bool值,代表其是否为回文结构。保证链表长度小
2016-07-14 09:41:02 329
原创 1002. A+B for Polynomials (25)
This time, you are supposed to find A+B where A and B are two polynomials.InputEach input file contains one test case. Each case occupies 2 lines, and each line contains the information of a p
2016-07-13 21:33:35 333
原创 1001. A+B Format (20)
Calculate a + b and output the sum in standard format -- that is, the digits must be separated into groups of three by commas (unless there are less than four digits).InputEach input file cont
2016-07-10 23:27:24 495
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人