摘要: One way to serialize a binary tree is to use pre-order traversal. When we encounter a non-null node, we record the node's value. If it is a null node, 阅读全文
posted @ 2017-10-24 21:53 daniel456 阅读(180) 评论(0) 推荐(0)
摘要: Given a non-negative integer num represented as a string, remove k digits from the number so that the new number is the smallest possible. Note: The l 阅读全文
posted @ 2017-10-24 21:43 daniel456 阅读(209) 评论(0) 推荐(0)
摘要: Given a sequence of n integers a1, a2, ..., an, a 132 pattern is a subsequence ai, aj, ak such that i < j < k and ai < ak < aj. Design an algorithm th 阅读全文
posted @ 2017-10-24 21:35 daniel456 阅读(215) 评论(0) 推荐(0)
摘要: You are given two arrays (without duplicates) nums1 and nums2 where nums1’s elements are subset of nums2. Find all the next greater numbers for nums1' 阅读全文
posted @ 2017-10-24 21:23 daniel456 阅读(130) 评论(0) 推荐(0)
摘要: Given a circular array (the next element of the last element is the first element of the array), print the Next Greater Number for every element. The 阅读全文
posted @ 2017-10-24 21:13 daniel456 阅读(127) 评论(0) 推荐(0)
摘要: Given a nested list of integers, implement an iterator to flatten it. Each element is either an integer, or a list -- whose elements may also be integ 阅读全文
posted @ 2017-10-24 20:57 daniel456 阅读(120) 评论(0) 推荐(0)
摘要: Implement the following operations of a queue using stacks. push(x) -- Push element x to the back of queue. pop() -- Removes the element from in front 阅读全文
posted @ 2017-10-24 20:53 daniel456 阅读(75) 评论(0) 推荐(0)
摘要: Implement the following operations of a stack using queues. push(x) -- Push element x onto stack. pop() -- Removes the element on top of the stack. to 阅读全文
posted @ 2017-10-24 20:50 daniel456 阅读(96) 评论(0) 推荐(0)
摘要: Implement a trie with insert, search, and startsWith methods. 题目含义:实现字典树的insert, search, 和startsWith 方法 字典树概念参考http://blog.csdn.net/u012501459/article 阅读全文
posted @ 2017-10-24 20:41 daniel456 阅读(110) 评论(0) 推荐(0)
摘要: Suppose you have N integers from 1 to N. We define a beautiful arrangement as an array that is constructed by these N numbers successfully if one of t 阅读全文
posted @ 2017-10-24 20:38 daniel456 阅读(141) 评论(0) 推荐(0)
摘要: A binary watch has 4 LEDs on the top which represent the hours (0-11), and the 6 LEDs on the bottom represent the minutes (0-59). Each LED represents 阅读全文
posted @ 2017-10-24 20:19 daniel456 阅读(98) 评论(0) 推荐(0)
摘要: Given a collection of distinct numbers, return all possible permutations. For example,[1,2,3] have the following permutations: [ [1,2,3], [1,3,2], [2, 阅读全文
posted @ 2017-10-24 20:08 daniel456 阅读(118) 评论(0) 推荐(0)
摘要: Given a list, rotate the list to the right by k places, where k is non-negative. For example:Given 1->2->3->4->5->NULL and k = 2,return 4->5->1->2->3- 阅读全文
posted @ 2017-10-24 16:56 daniel456 阅读(77) 评论(0) 推荐(0)
摘要: Given a linked list, return the node where the cycle begins. If there is no cycle, return null. Note: Do not modify the linked list. 题目含义:判断列表是否有环路,如果 阅读全文
posted @ 2017-10-24 16:47 daniel456 阅读(187) 评论(0) 推荐(0)
摘要: Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x. You should preserve the 阅读全文
posted @ 2017-10-24 16:44 daniel456 阅读(107) 评论(0) 推荐(0)
摘要: Given a singly linked list, determine if it is a palindrome. 题目含义:给定一个单列表,判断是否构成回文 阅读全文
posted @ 2017-10-24 16:28 daniel456 阅读(123) 评论(0) 推荐(0)
摘要: Given a linked list, remove the nth node from the end of list and return its head. For example, Note:Given n will always be valid.Try to do this in on 阅读全文
posted @ 2017-10-24 16:26 daniel456 阅读(98) 评论(0) 推荐(0)
摘要: Given a linked list, determine if it has a cycle in it. Follow up:Can you solve it without using extra space? 题目含义:判断一个列表是否有环路 思路:参考142. Linked List C 阅读全文
posted @ 2017-10-24 16:22 daniel456 阅读(138) 评论(0) 推荐(0)
摘要: Given a string and a string dictionary, find the longest string in the dictionary that can be formed by deleting some characters of the given string. 阅读全文
posted @ 2017-10-24 16:17 daniel456 阅读(129) 评论(0) 推荐(0)
摘要: Divide two integers without using multiplication, division and mod operator. If it is overflow, return MAX_INT. 题目含义:不要使用乘 除 取模,计算除法 方法一: 阅读全文
posted @ 2017-10-24 16:05 daniel456 阅读(141) 评论(0) 推荐(0)
摘要: Implement pow(x, n). 题目含义:实现x的n次方 阅读全文
posted @ 2017-10-24 15:46 daniel456 阅读(120) 评论(0) 推荐(0)
摘要: Follow up for H-Index: What if the citations array is sorted in ascending order? Could you optimize your algorithm? 题目含义:给定的数组是有序的,再次找h值 相关题目: 274. H- 阅读全文
posted @ 2017-10-24 15:43 daniel456 阅读(207) 评论(0) 推荐(0)
摘要: Given a sorted array, two integers k and x, find the k closest elements to x in the array. The result should also be sorted in ascending order. If the 阅读全文
posted @ 2017-10-24 15:40 daniel456 阅读(377) 评论(0) 推荐(0)
摘要: 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 i 阅读全文
posted @ 2017-10-24 15:36 daniel456 阅读(130) 评论(0) 推荐(0)
摘要: Given a set of intervals, for each of the interval i, check if there exists an interval j whose start point is bigger than or equal to the end point o 阅读全文
posted @ 2017-10-24 15:25 daniel456 阅读(156) 评论(0) 推荐(0)
摘要: Given a n x n matrix where each of the rows and columns are sorted in ascending order, find the kth smallest element in the matrix. Note that it is th 阅读全文
posted @ 2017-10-24 15:16 daniel456 阅读(214) 评论(0) 推荐(0)
摘要: You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality c 阅读全文
posted @ 2017-10-24 15:12 daniel456 阅读(135) 评论(0) 推荐(0)
摘要: We are playing the Guess Game. The game is as follows: I pick a number from 1 to n. You have to guess which number I picked. Every time you guess wron 阅读全文
posted @ 2017-10-24 15:10 daniel456 阅读(131) 评论(0) 推荐(0)
摘要: There are a total of n courses you have to take, labeled from 0 to n - 1. Some courses may have prerequisites, for example to take course 0 you have t 阅读全文
posted @ 2017-10-24 14:42 daniel456 阅读(123) 评论(0) 推荐(0)
摘要: Given a matrix consists of 0 and 1, find the distance of the nearest 0 for each cell. The distance between two adjacent cells is 1. Example 1: Input: 阅读全文
posted @ 2017-10-24 14:25 daniel456 阅读(195) 评论(0) 推荐(0)
摘要: Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST. 题目含义:给定一个升序的列表,构造一个平衡二叉树 平衡二叉树:二叉排序树集中了数 阅读全文
posted @ 2017-10-24 14:16 daniel456 阅读(121) 评论(0) 推荐(0)
摘要: Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacen 阅读全文
posted @ 2017-10-24 14:05 daniel456 阅读(141) 评论(0) 推荐(0)
摘要: Given an integer array, your task is to find all the different possible increasing subsequences of the given array, and the length of an increasing su 阅读全文
posted @ 2017-10-24 13:57 daniel456 阅读(219) 评论(0) 推荐(0)
摘要: Given an encoded string, return it's decoded string. The encoding rule is: k[encoded_string], where the encoded_string inside the square brackets is b 阅读全文
posted @ 2017-10-24 13:52 daniel456 阅读(195) 评论(0) 推荐(0)
摘要: There are N students in a class. Some of them are friends, while some are not. Their friendship is transitive in nature. For example, if A is a direct 阅读全文
posted @ 2017-10-24 13:45 daniel456 阅读(222) 评论(0) 推荐(0)
摘要: Given a binary tree, return all root-to-leaf paths. For example, given the following binary tree: All root-to-leaf paths are: 阅读全文
posted @ 2017-10-24 13:32 daniel456 阅读(114) 评论(0) 推荐(0)
摘要: Given two integers representing the numerator and denominator of a fraction, return the fraction in string format. If the fractional part is repeating 阅读全文
posted @ 2017-10-24 13:24 daniel456 阅读(124) 评论(0) 推荐(0)
摘要: Design a simplified version of Twitter where users can post tweets, follow/unfollow another user and is able to see the 10 most recent tweets in the u 阅读全文
posted @ 2017-10-24 11:41 daniel456 阅读(174) 评论(0) 推荐(0)
摘要: A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null. Return a deep copy 阅读全文
posted @ 2017-10-24 11:31 daniel456 阅读(128) 评论(0) 推荐(0)
摘要: All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: "ACGAATTCCG". When studying DNA, it is sometimes useful to 阅读全文
posted @ 2017-10-24 11:24 daniel456 阅读(345) 评论(0) 推荐(0)
摘要: Given an array of citations (each citation is a non-negative integer) of a researcher, write a function to compute the researcher's h-index. According 阅读全文
posted @ 2017-10-24 11:18 daniel456 阅读(152) 评论(0) 推荐(0)
摘要: You are playing the following Bulls and Cows game with your friend: You write down a number and ask your friend to guess what the number is. Each time 阅读全文
posted @ 2017-10-24 11:14 daniel456 阅读(150) 评论(0) 推荐(0)
摘要: Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules. The Sudoku board could be partially filled, where empty cells are filled wit 阅读全文
posted @ 2017-10-24 11:04 daniel456 阅读(96) 评论(0) 推荐(0)
摘要: Given a binary array, find the maximum length of a contiguous subarray with equal number of 0 and 1. Example 1: Example 2: 阅读全文
posted @ 2017-10-24 10:52 daniel456 阅读(95) 评论(0) 推荐(0)
摘要: There is a brick wall in front of you. The wall is rectangular and has several rows of bricks. The bricks have the same height but different width. Yo 阅读全文
posted @ 2017-10-24 10:49 daniel456 阅读(110) 评论(0) 推荐(0)
摘要: Given four lists A, B, C, D of integer values, compute how many tuples (i, j, k, l) there are such that A[i] + B[j] + C[k] + D[l]is zero. To make prob 阅读全文
posted @ 2017-10-24 10:45 daniel456 阅读(95) 评论(0) 推荐(0)
摘要: In English, we have a concept called root, which can be followed by some other words to form another longer word - let's call this word successor. For 阅读全文
posted @ 2017-10-24 10:39 daniel456 阅读(171) 评论(0) 推荐(0)
摘要: Given a non-empty array of integers, return the k most frequent elements. For example,Given [1,1,1,2,2,3] and k = 2, return [1,2]. Note: You may assum 阅读全文
posted @ 2017-10-24 10:34 daniel456 阅读(87) 评论(0) 推荐(0)
摘要: Implement a magic directory with buildDict, and search methods. For the method buildDict, you'll be given a list of non-repetitive words to build a di 阅读全文
posted @ 2017-10-24 10:31 daniel456 阅读(130) 评论(0) 推荐(0)