摘要: 摘自:http://www.cnblogs.com/Leo_wl/p/3409096.html#commentform 硬是没找到在哪儿转载。。题目要求Linked List CycleGiven a linked list, determine if it has a cycle in it.Fo... 阅读全文
posted @ 2015-10-06 11:35 Nily 阅读(766) 评论(0) 推荐(0)
摘要: 题目:Given a string s and a dictionary of words dict, determine if s can be break into a space-separated sequence of one or more dictionary words.Exampl... 阅读全文
posted @ 2015-09-20 10:03 Nily 阅读(242) 评论(0) 推荐(0)
摘要: 题目:Given the root and two nodes in a Binary Tree. Find the lowest common ancestor(LCA) of the two nodes.The lowest common ancestor is the node with la... 阅读全文
posted @ 2015-09-17 14:48 Nily 阅读(597) 评论(0) 推荐(0)
摘要: 题目:Given a binary tree, find the maximum path sum.The path may start and end at any node in the tree.ExampleGiven the below binary tree: 1 / \2 3re... 阅读全文
posted @ 2015-09-17 11:28 Nily 阅读(165) 评论(0) 推荐(0)
摘要: 题目:给一副扑克牌和一个随机数函数,设计一个洗牌算法。解析:最直观的思路是什么?很简单,每次从牌堆中随机地拿一张出来。那么,第一次拿有52种可能,拿完后剩下51张;第二次拿有51种可能,第三次拿有50种可能,…,一直这样随机地拿下去直到拿完最后1张,我们就从52!种可能中取出了一种排列,这个排列对应... 阅读全文
posted @ 2015-09-17 11:21 Nily 阅读(657) 评论(0) 推荐(0)
摘要: // boundary value testingint start = 0;int end = size - 1;int mid;while (start + 1 < end) { // 相邻或相交跳出循环 mid = start + (end - start) / 2; //装逼用,不直... 阅读全文
posted @ 2015-09-10 11:13 Nily 阅读(180) 评论(0) 推荐(0)
摘要: 题目描述:Given an array of integers, every element appearstwiceexcept for one. Find that single one.Note:Your algorithm should have a linear runtime compl... 阅读全文
posted @ 2015-04-12 13:09 Nily 阅读(140) 评论(0) 推荐(0)
摘要: 一个难度为Easy的题,看了好多人的题解都没想明白,最后使劲想使劲想,才想的差不多。。太弱了,要找不到工作了。。题目描述:The string"PAYPALISHIRING"is written in a zigzag pattern on a given number of rows like t... 阅读全文
posted @ 2015-04-12 13:00 Nily 阅读(485) 评论(0) 推荐(0)