03 2013 档案

1 sec on Large Judge (java): https://github.com/l...
摘要:1 sec on Large Judge (java): https://github.com/leoyonn/leetcode/blob/master/src/q029_substring_of_all_words/Solution.java 阅读全文

posted @ 2013-03-31 18:45 小刀初试 阅读(90) 评论(0) 推荐(0) 编辑

[LeetCode] Path Sum, Solution
摘要:Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.Fo... 阅读全文

posted @ 2013-03-24 02:44 小刀初试 阅读(95) 评论(0) 推荐(0) 编辑

嗯哪
摘要:嗯哪 阅读全文

posted @ 2013-03-24 02:27 小刀初试 阅读(83) 评论(0) 推荐(0) 编辑

[Interview] Serialize and De-serialize a tree
摘要:A very frequent interview question. Suppose you have a tree, how could you serialize it to file and revert it back?for example, ... 阅读全文

posted @ 2013-03-23 08:43 小刀初试 阅读(136) 评论(0) 推荐(0) 编辑

[LeetCode] Convert Sorted Array to Binary Search Tree, Solution
摘要:Given an array where elements are sorted in ascending order, convert it to a height balanced BST.» Solve this problem[Thoughts][Code]1: TreeNode... 阅读全文

posted @ 2013-03-23 08:40 小刀初试 阅读(98) 评论(0) 推荐(0) 编辑

[LeetCode] Same Tree, Solution
摘要:Given two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally identical an... 阅读全文

posted @ 2013-03-22 13:33 小刀初试 阅读(86) 评论(0) 推荐(0) 编辑

设计题
摘要:设计一个系统,每次用户访问,生成一个唯一的ID,支持千万用户同时访问。 阅读全文

posted @ 2013-03-22 02:13 小刀初试 阅读(93) 评论(0) 推荐(0) 编辑

海量数据处理总结
摘要:前言 一般而言,标题含有“秒杀”,“99%”,“史上最全/最强”等词汇的往往都脱不了哗众取宠之嫌,但进一步来讲,如果读者读罢此文,却无任何收获,那么,我也甘愿背负这样的罪名,:-),同时,此文可以看做是对这篇文章:十道海量数据处理面试题与十个方法大总结的一般抽象性总结。 毕竟受文章和理论之... 阅读全文

posted @ 2013-03-22 02:12 小刀初试 阅读(140) 评论(0) 推荐(0) 编辑

图搜索
摘要:1. 介绍本文介绍了比较初级的图搜索算法,包括深度优先遍历,广度优先遍历和双向广度优先遍历。2. 深度优先遍历DFS2.1 算法思想从图中某个顶点v开始,访问此节点,然后依次从v中未被访问的邻接点出发深度优先遍历图,直到图中上所有和v有路径相通的顶点都被访问;若此时图中尚有顶点未被访问,则另选图中一... 阅读全文

posted @ 2013-03-22 02:12 小刀初试 阅读(367) 评论(0) 推荐(0) 编辑

[LeetCode] Unique Binary Search Trees II, Solution
摘要:Given n, generate all structurally unique BST's (binary search trees) that store values 1...n.For example,Given n = 3, your program should return all ... 阅读全文

posted @ 2013-03-21 11:34 小刀初试 阅读(99) 评论(0) 推荐(0) 编辑

[LeetCode] Unique Binary Search Trees, Solution
摘要:Given n, how many structurally unique BST's (binary search trees) that store values 1...n?For example,Given n = 3, there are a total of 5 unique BST's... 阅读全文

posted @ 2013-03-21 10:48 小刀初试 阅读(130) 评论(0) 推荐(0) 编辑

[LeetCode] Remove Duplicates from Sorted List II, Solution
摘要:Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list.For example,Given 1->2-... 阅读全文

posted @ 2013-03-19 10:48 小刀初试 阅读(141) 评论(0) 推荐(0) 编辑

[LeetCode] Search a 2D Matrix, Solution
摘要:Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:Integers in each row are sorted fr... 阅读全文

posted @ 2013-03-18 05:44 小刀初试 阅读(129) 评论(0) 推荐(0) 编辑

[LeetCode] Merge Two Sorted Lists, Solution
摘要:Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.» Solve... 阅读全文

posted @ 2013-03-17 05:06 小刀初试 阅读(183) 评论(0) 推荐(0) 编辑

恩,我用了double...精度比float更高,所以没出溢出问题。
摘要:恩,我用了double...精度比float更高,所以没出溢出问题。 阅读全文

posted @ 2013-03-17 01:42 小刀初试 阅读(161) 评论(0) 推荐(0) 编辑

我也写了一个牛顿迭代法,貌似不需要特殊处理溢出的情况 class Solution { public...
摘要:我也写了一个牛顿迭代法,貌似不需要特殊处理溢出的情况class Solution {public:int sqrt(int x) {if (x ==0) return 0; double pre_t; double cur_t = 1; ... 阅读全文

posted @ 2013-03-17 01:38 小刀初试 阅读(514) 评论(0) 推荐(0) 编辑

[LeetCode] Longest Valid Parentheses, Solution
摘要:Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring.For "(()", the lon... 阅读全文

posted @ 2013-03-11 11:54 小刀初试 阅读(124) 评论(0) 推荐(0) 编辑

[LeetCode] Two Sum, Solution
摘要:Given an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two nu... 阅读全文

posted @ 2013-03-05 12:34 小刀初试 阅读(156) 评论(0) 推荐(0) 编辑

[LeetCode] Palindrome Partitioning II, Solution
摘要:Given a string s, partition s such that every substring of the partition is a palindrome.Return the minimum cuts needed for a palindrome partitioning ... 阅读全文

posted @ 2013-03-05 11:57 小刀初试 阅读(132) 评论(0) 推荐(0) 编辑

[LeetCode] Palindrome Partitioning, Solution
摘要:Given a string s, partition s such that every substring of the partition is a palindrome.Return all possible palindrome partitioning of s.For example,... 阅读全文

posted @ 2013-03-04 12:52 小刀初试 阅读(117) 评论(0) 推荐(0) 编辑

[LeetCode] Surrounded Regions, Solution
摘要:Given a 2D board containing 'X' and 'O', capture all regions surrounded by 'X'.A region is captured by flipping all 'O's into 'X's in that surrounded ... 阅读全文

posted @ 2013-03-04 09:56 小刀初试 阅读(164) 评论(0) 推荐(0) 编辑

the complexity is no longer O(lgn), right?
摘要:the complexity is no longer O(lgn), right? 阅读全文

posted @ 2013-03-01 07:25 小刀初试 阅读(91) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示