摘要: http://www.lintcode.com/en/problem/longest-increasing-continuous-subsequence/# Give you an integer array (index from 0 to n-1, where n is the size of this array),find the longest increasing cont... 阅读全文
posted @ 2015-05-26 11:49 Acjx 阅读(721) 评论(0) 推荐(0) 编辑
摘要: Given a collection of numbers that might contain duplicates, return all possible unique permutations. For example, [1,1,2] have the following unique permutations: [1,1,2], [1,2,1], an... 阅读全文
posted @ 2015-05-24 00:12 Acjx 阅读(658) 评论(0) 推荐(0) 编辑
摘要: http://www.lintcode.com/en/problem/permutations/# Given a list of numbers, return all possible permutations. Example For nums = [1,2,3], the permutations are: [ [1,2,3], [1,3,2], ... 阅读全文
posted @ 2015-05-22 22:34 Acjx 阅读(869) 评论(0) 推荐(0) 编辑
摘要: http://www.lintcode.com/zh-cn/problem/topological-sorting/# 给定一个有向图,图节点的拓扑排序被定义为: 对于每条有向边A--> B,则A必须排在B之前 拓扑排序的第一个节点可以是任何在图中没有其他节点指向它的节点 找到给定图的任一拓扑排序 solution Topologi... 阅读全文
posted @ 2015-05-22 21:20 Acjx 阅读(630) 评论(0) 推荐(0) 编辑
摘要: https://leetcode.com/problems/search-in-rotated-sorted-array-ii/ Follow up for "Search in Rotated Sorted Array": What if duplicates are allowed? Would this affect the run-time complexity?... 阅读全文
posted @ 2015-05-22 19:18 Acjx 阅读(202) 评论(0) 推荐(0) 编辑
摘要: https://leetcode.com/problems/search-in-rotated-sorted-array/ Suppose a sorted array is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2). Y... 阅读全文
posted @ 2015-05-22 17:03 Acjx 阅读(288) 评论(0) 推荐(0) 编辑
摘要: https://leetcode.com/problems/search-insert-position/ Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inse... 阅读全文
posted @ 2015-05-22 11:57 Acjx 阅读(226) 评论(0) 推荐(0) 编辑
摘要: http://www.lintcode.com/zh-cn/problem/word-ladder-ii/# 给出两个单词(start和end)和一个字典,找出所有从start到end的最短转换序列 比如: 每次只能改变一个字母。 变换过程中的中间单词必须在字典中出现。 样例 给出数据如下: start... 阅读全文
posted @ 2015-05-21 19:24 Acjx 阅读(410) 评论(0) 推荐(0) 编辑
摘要: 再来看以下具体例子: 阅读全文
posted @ 2015-05-19 21:50 Acjx 阅读(556) 评论(0) 推荐(0) 编辑
摘要: https://leetcode.com/problems/word-ladder/ http://www.lintcode.com/zh-cn/problem/word-ladder/ 给出两个单词(start和end)和一个字典,找到从start到end的最短转换序列 比如: 每次只能改变一个字母。 变换过程中的中间单词必须在... 阅读全文
posted @ 2015-05-19 18:55 Acjx 阅读(647) 评论(0) 推荐(0) 编辑
摘要: 题目描述 用两个栈来实现一个队列,完成队列的Push和Pop操作。 队列中的元素为int类型。 水题,直接上代码: class Solution { public: void push(int node) { stack1.push(node); } int pop() { if (stack2.empty()) { while (... 阅读全文
posted @ 2015-05-11 12:38 Acjx 阅读(394) 评论(0) 推荐(0) 编辑
摘要: https://leetcode.com/problems/longest-substring-without-repeating-characters/ Given a string, find the length of the longest substring without repeating characters. For example, the longest subs... 阅读全文
posted @ 2015-05-10 21:57 Acjx 阅读(249) 评论(0) 推荐(1) 编辑
摘要: 题目描述 输入某二叉树的前序遍历和中序遍历的结果,请重建出该二叉树。假设输入的前序遍历和中序遍历的结果中都不含重复的数字。例如输入前序遍历序列{1,2,4,7,3,5,6,8}和中序遍历序列{4,7,2,1,5,3,8,6},则重建二叉树并输出它的后序遍历序列。(测试用例中,"树"的输出形式类似于树的层次遍历,没有节点的用#来代替) 除了一些编译错误,一遍AC了,真是爽。由... 阅读全文
posted @ 2015-05-10 19:34 Acjx 阅读(359) 评论(0) 推荐(0) 编辑
摘要: 题目描述 输入一个链表,从尾到头打印链表每个节点的值。 题目比较水,一遍就 AC 了,来看代码:/** * struct ListNode { * int val; * struct ListNode *next; * ListNode(int x) : * val(x), next(NULL) { * } * }; */ class Solution... 阅读全文
posted @ 2015-05-10 18:26 Acjx 阅读(295) 评论(0) 推荐(0) 编辑
摘要: 题目描述 请实现一个函数,将一个字符串中的空格替换成“%20”。例如,当字符串为We Are Happy.则经过替换之后的字符串为We%20Are%20Happy。 最直接的方式,直接使用 STL。假设字符串的长度是n,那么对于每个空格字符,需要移动后面 o(n) 个字符,因此对含有 o(n) 个空格字符的字符串而言时间复杂度为 o(n2),过高了。代码如下: class... 阅读全文
posted @ 2015-05-10 17:23 Acjx 阅读(306) 评论(0) 推荐(0) 编辑
摘要: 题目描述 在一个二维数组中,每一行都按照从左到右递增的顺序排序,每一列都按照从上到下递增的顺序排序。请完成一个函数,输入这样的一个二维数组和一个整数,判断数组中是否含有该整数。 来分析下,假设在数组中随便找一个数字 inner_number 来与 target 进行比较,如果 target > inner_number,那么我们需要在数组中剔除掉 inner_numb... 阅读全文
posted @ 2015-05-10 15:56 Acjx 阅读(417) 评论(0) 推荐(0) 编辑
摘要: https://leetcode.com/problems/binary-tree-level-order-traversal-ii/ http://www.lintcode.com/zh-cn/problem/binary-tree-level-order-traversal-ii/# Given a binary tree, return the bottom-up leve... 阅读全文
posted @ 2015-05-09 18:54 Acjx 阅读(383) 评论(0) 推荐(0) 编辑
摘要: https://leetcode.com/problems/binary-tree-level-order-traversal/ http://www.lintcode.com/zh-cn/problem/binary-tree-level-order-traversal/# Given a binary tree, return the level order traversa... 阅读全文
posted @ 2015-05-09 18:31 Acjx 阅读(295) 评论(0) 推荐(0) 编辑
摘要: https://leetcode.com/problems/valid-palindrome/ Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. For example, "A man, a plan... 阅读全文
posted @ 2015-05-05 10:52 Acjx 阅读(468) 评论(0) 推荐(0) 编辑
摘要: 4.1 Introduction 4.2 stat, fstat, fstatat, and lstat Functions The lstat function is similar to stat, but when the named file is a symbolic link, lstat returns information about the symbolic link,... 阅读全文
posted @ 2015-05-04 21:57 Acjx 阅读(715) 评论(0) 推荐(0) 编辑