摘要:
原题链接:http://oj.leetcode.com/problems/merge-k-sorted-lists/题目描述:Mergeksorted linked lists and return it as one sorted list. Analyze and describe its complexity.题解: 这是个典型的分治题,用递归,不断平分,解决merge两个有序链表的小问题即可。 1 /** 2 * Definition for singly-linked list. 3 * struct ListNode { 4 * int val; 5 * ... 阅读全文
阅读排行榜
[LeetCode]Evaluate Reverse Polish Notation(逆波兰式的计算)
2013-12-21 00:21 by 庸男勿扰, 345 阅读, 收藏,
摘要:
原题链接:http://oj.leetcode.com/problems/evaluate-reverse-polish-notation/题目描述:Evaluate the value of an arithmetic expression inReverse Polish Notation.Valid operators are+,-,*,/. Each operand may be an integer or another expression.Some examples: ["2", "1", "+", "3&qu 阅读全文
[九度OJ]1078.二叉树的遍历(重建)
2013-09-14 11:47 by 庸男勿扰, 319 阅读, 收藏,
摘要:
原题链接:http://ac.jobdu.com/problem.php?pid=1078题目描述:二叉树的前序、中序、后序遍历的定义:前序遍历:对任一子树,先访问跟,然后遍历其左子树,最后遍历其右子树;中序遍历:对任一子树,先遍历其左子树,然后访问根,最后遍历其右子树;后序遍历:对任一子树,先遍历其左子树,然后遍历其右子树,最后访问根。给定一棵二叉树的前序遍历和中序遍历,求其后序遍历(提示:给定前序遍历与中序遍历能够唯一确定后序遍历)。输入:两个字符串,其长度n均小于等于26。第一行为前序遍历,第二行为中序遍历。二叉树中的结点名称以大写字母表示:A,B,C....最多26个结点。输出:输入样 阅读全文
[LeetCode]Reverse Words in a String
2014-03-09 19:02 by 庸男勿扰, 317 阅读, 收藏,
摘要:
原题链接:http://oj.leetcode.com/problems/reverse-words-in-a-string/题目描述:Given an input string, reverse the string word by word.For example,Given s = "the sky is blue",return "blue is sky the".click to show clarification.Clarification:What constitutes a word?A sequence of non-space ch 阅读全文
[微软实习生2014]K-th string
2014-05-17 18:32 by 庸男勿扰, 281 阅读, 收藏,
摘要:
很久之前的事情了,微软2014实习生的在线测试题,记录下来以备后用。题目描述:DescriptionConsider a string set that each of them consists of {0, 1} only. All strings in the set have the sam... 阅读全文
浙公网安备 33010602011771号