摘要:1 sec on Large Judge (java): https://github.com/leoyonn/leetcode/blob/master/src/q029_substring_of_all_words/Solution.java
阅读全文
摘要: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...
阅读全文
摘要:A very frequent interview question. Suppose you have a tree, how could you serialize it to file and revert it back?for example, ...
阅读全文
摘要:Given an array where elements are sorted in ascending order, convert it to a height balanced BST.» Solve this problem[Thoughts][Code]1: TreeNode...
阅读全文
摘要: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...
阅读全文
摘要:设计一个系统,每次用户访问,生成一个唯一的ID,支持千万用户同时访问。
阅读全文
摘要:前言 一般而言,标题含有“秒杀”,“99%”,“史上最全/最强”等词汇的往往都脱不了哗众取宠之嫌,但进一步来讲,如果读者读罢此文,却无任何收获,那么,我也甘愿背负这样的罪名,:-),同时,此文可以看做是对这篇文章:十道海量数据处理面试题与十个方法大总结的一般抽象性总结。 毕竟受文章和理论之...
阅读全文
摘要:1. 介绍本文介绍了比较初级的图搜索算法,包括深度优先遍历,广度优先遍历和双向广度优先遍历。2. 深度优先遍历DFS2.1 算法思想从图中某个顶点v开始,访问此节点,然后依次从v中未被访问的邻接点出发深度优先遍历图,直到图中上所有和v有路径相通的顶点都被访问;若此时图中尚有顶点未被访问,则另选图中一...
阅读全文
摘要: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 ...
阅读全文
摘要: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...
阅读全文
摘要: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-...
阅读全文
摘要: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...
阅读全文
摘要: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...
阅读全文
摘要:恩,我用了double...精度比float更高,所以没出溢出问题。
阅读全文
摘要:我也写了一个牛顿迭代法,貌似不需要特殊处理溢出的情况class Solution {public:int sqrt(int x) {if (x ==0) return 0; double pre_t; double cur_t = 1; ...
阅读全文
摘要:Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring.For "(()", the lon...
阅读全文
摘要: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...
阅读全文
摘要: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 ...
阅读全文
摘要: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,...
阅读全文
摘要: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 ...
阅读全文
摘要:the complexity is no longer O(lgn), right?
阅读全文