数据结构
peace in mind
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
[leetcode] Generate Parentheses
题目链接在此 醉了。easy难度的题刷得差不多了,找了几道medium的开始刷。发现不差下别人怎么写的,很难下手。哎。修炼不够啊。决定leetcode缓一缓,先看看其他专业书。 Given n pairs of parentheses, write a function to generate all combinations of well-formed parenthese转载 2015-08-12 17:35:10 · 425 阅读 · 0 评论 -
[Leetcode] Binary Tree Level Order Traversal & Binary Tree Zigzag Level Order Traversal
这是两道题: 102. Binary Tree Level Order Traversal 103. Binary Tree Zigzag Level Order Traversal 102这道题就是按层次遍历,但是要把每一层的节点分别存储到vector里面去。 两年前就做过这道题,还写了博客。 当时的做法是硬生生地给每个结点加了个域,用来标记高度。很蹩脚。 今天做10原创 2017-03-14 18:29:13 · 434 阅读 · 0 评论 -
[LeetCode] Next Greater Element I
题目链接在此 You are given two arrays (without duplicates) nums1 and nums2 where nums1’s elements are subset of nums2. Find all the next greater numbers for nums1's elements in the correspondin原创 2017-02-16 23:33:09 · 408 阅读 · 0 评论 -
Sicily. 整数划分
Description 对于一个整数m,m > 0,它可以写成t个整数的和的形式(t>0): m = z1 + z2 + … + zt ,其中zi > 0且为整数(1≤i≤t) 这t个整数就是整数m的一种划分。 比如整数4有以下5种划分: 4 3+1 2+2 2+1+1 1+1+1+1 Input 第一行是一个整数n,代表有n个测试用例 接下来的n行每一转载 2015-10-10 22:13:33 · 1016 阅读 · 0 评论 -
Sicily. 全排序输出
输入一个数字n,输出从1~n组成的数字的全排列,每个排列占一行,输出按照数值升序排列 比如输入3,则输出是: 123 132 213 231 312 321 递归算法。转自这位大神 #include #include using namespace std; void permutation(string pre, string rem转载 2015-10-10 15:27:50 · 673 阅读 · 0 评论 -
sicily. 放鸡蛋(输出情况总数+输出具体情况)
Time Limit: 1sec Memory Limit:256MB Description 把M个同样的鸡蛋放在N个同样的篮子里,允许有的篮子空着不放,问共有多少种不同的放法? 5,1,1和1,5,1是同一种分法。 Input 第一行是测试数据的数目t(0 )。以下每行均包含二个整数M和N,以空格分开。1,N。 Output 对输入的每组原创 2015-10-10 22:27:19 · 1035 阅读 · 0 评论 -
[leetcode] Implement strStr()
题目链接在此 Implement strStr(). Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack. 模式匹配。KMP咯。说起KMP的话,自从大一上学C语言开始就有所了解,但是只知道它的用途和大概原理,从没下过功夫落实转载 2015-08-13 11:22:20 · 472 阅读 · 0 评论 -
[leetcode] Implement Stack using Queues
题目链接在此。 Implement the following operations of a stack using queues. push(x) -- Push element x onto stack.pop() -- Removes the element on top of the stack.top() -- Get the top element.empty原创 2015-07-31 16:12:08 · 412 阅读 · 0 评论 -
[leetcode] Implement Queue using Stacks
题目链接在此。 Implement the following operations of a queue using stacks. push(x) -- Push element x to the back of queue.pop() -- Removes the element from in front of queue.peek() -- Get the fro原创 2015-07-31 15:10:14 · 450 阅读 · 0 评论 -
Sicily. 完整计算器(浮点数;四则运算与括号)
Time Limit: 1sec Memory Limit:256MB Description 请实现一个只包含加减乘除以及括号运算的简单计算器,忽略式子中的所有空格,输入格式是正确的,不需要判断。 Input 第一行只有一个整数m,代表有m个测试用例 接下来有m行,每一行是一个测试用例,代表要求计算的式子,请注意输入的数字可能有小数。原创 2015-10-09 17:24:11 · 3091 阅读 · 0 评论
分享