上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 13 下一页
摘要: 这道题目本身没什么特色。 但是涉及到一个问题,即快慢指针的问题。 犹记得面试微软的那道快慢指针找链表环的问题。 这里快慢指针还有个妙用。即求一个链表的中点。 记之 阅读全文
posted @ 2016-06-21 17:35 ElNinoT 阅读(108) 评论(0) 推荐(0) 编辑
摘要: 先上题目 Given two words (beginWord and endWord), and a dictionary's word list, find the length of shortest transformation sequence from beginWord to endW 阅读全文
posted @ 2016-06-03 10:03 ElNinoT 阅读(209) 评论(0) 推荐(0) 编辑
摘要: 题目 Say you have an array for which the ith element is the price of a given stock on day i. If you were only permitted to complete at most one transact 阅读全文
posted @ 2016-06-01 10:48 ElNinoT 阅读(186) 评论(0) 推荐(0) 编辑
摘要: Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below. For example, given the fo 阅读全文
posted @ 2016-05-31 17:56 ElNinoT 阅读(103) 评论(0) 推荐(0) 编辑
摘要: 题目: Given a binary tree, determine if it is a valid binary search tree (BST). Assume a BST is defined as follows: The left subtree of a node contains 阅读全文
posted @ 2016-05-30 10:13 ElNinoT 阅读(91) 评论(0) 推荐(0) 编辑
摘要: 这道题如下: Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2. For example,Given:s1 = "aabcc",s2 = "dbbca", When s3 = "aadbbcbca 阅读全文
posted @ 2016-05-27 11:46 ElNinoT 阅读(101) 评论(0) 推荐(0) 编辑
摘要: 这道题如下: Given n, generate all structurally unique BST's (binary search trees) that store values 1...n. For example,Given n = 3, your program should ret 阅读全文
posted @ 2016-05-26 16:54 ElNinoT 阅读(133) 评论(0) 推荐(0) 编辑
摘要: backtracing是一个常用的解法。之前遇到一个题目,求一个集合的子集, 例如给定{1,2,3,4,5},求其大小为3的子集。 利用backtracing可以较快的给出答案。 然而,该题还有一个变种,即如果集合中有重复的元素怎么办。 例如,{1,1,1,2,2,3,4,5} 依然使用backtr 阅读全文
posted @ 2016-05-23 17:10 ElNinoT 阅读(119) 评论(0) 推荐(0) 编辑
摘要: 上一篇文章讲了该题的一个解法。后来又发现一个更好的解法。 首先依旧考虑一个升序的数列,例如1,2,3,4,5。那么它的最大矩形显然是有5种可能,即 1*5,2*4,3*3,4*2,1*5。所以最大的矩形为9。那么显然不可能是升序的数列。 依据以下几条规则对其进行处理。 有栈stack和待处理数组a[ 阅读全文
posted @ 2016-05-19 12:47 ElNinoT 阅读(156) 评论(0) 推荐(0) 编辑
摘要: 直方图上的最大矩形。这道题很有意思。研究了半天才研究出来是个什么意思。 首先看题目: Given n non-negative integers representing the histogram's bar height where the width of each bar is 1, fin 阅读全文
posted @ 2016-05-18 15:32 ElNinoT 阅读(165) 评论(0) 推荐(0) 编辑
上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 13 下一页