Fork me on GitHub

03 2017 档案

摘要:Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and 阅读全文
posted @ 2017-03-31 14:33 hellowOOOrld 阅读(185) 评论(0) 推荐(0)
摘要:Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root). For 阅读全文
posted @ 2017-03-29 21:58 hellowOOOrld 阅读(190) 评论(0) 推荐(0)
摘要:Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level). For example: Given binary tree [ 阅读全文
posted @ 2017-03-29 21:45 hellowOOOrld 阅读(702) 评论(0) 推荐(0)
摘要:Given two integers n and k, return all possible combinations of k numbers out of 1 ... n. For example, If n = 4 and k = 2, a solution is: [ [2,4], [3, 阅读全文
posted @ 2017-03-29 17:18 hellowOOOrld 阅读(220) 评论(0) 推荐(0)
摘要:Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). For example, this binary tree [1,2,2,3,4,4,3] is symmet 阅读全文
posted @ 2017-03-28 23:13 hellowOOOrld 阅读(223) 评论(0) 推荐(0)
摘要: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. 思路: 由于链表 阅读全文
posted @ 2017-03-27 22:55 hellowOOOrld 阅读(215) 评论(0) 推荐(0)
摘要:Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST. 思路:利用快慢指针找到中间节点,作为根节点,然后左子树即为左边链表部分,右子树即 阅读全文
posted @ 2017-03-26 23:27 hellowOOOrld 阅读(858) 评论(0) 推荐(0)
摘要:We define the Perfect Number is a positive integer that is equal to the sum of all its positive divisors except itself. Now, given an integer n, write 阅读全文
posted @ 2017-03-26 11:16 hellowOOOrld 阅读(332) 评论(0) 推荐(0)
摘要:Given two strings representing two complex numbers. You need to return a string representing their multiplication. Note i2 = -1 according to the defin 阅读全文
posted @ 2017-03-26 11:13 hellowOOOrld 阅读(490) 评论(0) 推荐(0)
摘要:Given an array where elements are sorted in ascending order, convert it to a height balanced BST. 思路: 由于是有序数组,那么根节点肯定是中间的那个数字,然后递归处理左子树和右子树即可。 阅读全文
posted @ 2017-03-23 16:53 hellowOOOrld 阅读(171) 评论(0) 推荐(0)
摘要:Given a binary tree, find the maximum path sum. For this problem, a path is defined as any sequence of nodes from some starting node to any node in th 阅读全文
posted @ 2017-03-23 15:18 hellowOOOrld 阅读(165) 评论(0) 推荐(0)
摘要:Given a string, find the length of the longest substring without repeating characters. Examples: Given "abcabcbb", the answer is "abc", which the leng 阅读全文
posted @ 2017-03-16 16:53 hellowOOOrld 阅读(157) 评论(0) 推荐(0)
摘要:Implement pow(x, n). 开始的时候思路很朴素,隐约觉得不太对劲。。果然,超时了。 然后,再仔细琢磨,发现可以缩短时间,缩短到 O(lgn)的复杂度。 比如8个2相乘的话,可以表示为4的平方,4又可以表示为2的平方,只需三次即可算出。 参考: https://discuss.leet 阅读全文
posted @ 2017-03-15 17:06 hellowOOOrld 阅读(172) 评论(0) 推荐(0)
摘要:A message containing letters from A-Z is being encoded to numbers using the following mapping: 'A' -> 1 'B' -> 2 ... 'Z' -> 26 Given an encoded messag 阅读全文
posted @ 2017-03-15 15:43 hellowOOOrld 阅读(174) 评论(0) 推荐(0)
摘要:Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.) You have 阅读全文
posted @ 2017-03-14 20:20 hellowOOOrld 阅读(164) 评论(0) 推荐(0)
摘要:Given two binary strings, return their sum (also a binary string). For example, a = "11" b = "1" Return "100". 思路: 模拟加法时候的情形,从最后一位开始进行相加,注意进位的情况。 阅读全文
posted @ 2017-03-14 15:44 hellowOOOrld 阅读(152) 评论(0) 推荐(0)
摘要:转载:https://aitanlu.com/ubuntu-***-ke-hu-duan-pei-zhi.html 之前介绍过用搬瓦工的vps(搬瓦工不用vpn已经打不开了)轻松的搭建***服务,也可以参考linux-ubuntu下搭建***,然后在w 阅读全文
posted @ 2017-03-13 23:24 hellowOOOrld 阅读(7) 评论(0) 推荐(0)
摘要:Given an array of integers, every element appears three times except for one, which appears exactly once. Find that single one. Note:Your algorithm sh 阅读全文
posted @ 2017-03-13 23:19 hellowOOOrld 阅读(174) 评论(0) 推荐(0)
摘要:The set [1,2,3,…,n] contains a total of n! unique permutations. By listing and labeling all of the permutations in order, We get the following sequenc 阅读全文
posted @ 2017-03-13 16:43 hellowOOOrld 阅读(166) 评论(0) 推荐(0)
摘要:Given an array of non-negative integers, you are initially positioned at the first index of the array. Each element in the array represents your maxim 阅读全文
posted @ 2017-03-12 19:08 hellowOOOrld 阅读(114) 评论(0) 推荐(0)
摘要:Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array whic 阅读全文
posted @ 2017-03-10 15:55 hellowOOOrld 阅读(233) 评论(0) 推荐(0)
摘要:Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of 阅读全文
posted @ 2017-03-10 10:24 hellowOOOrld 阅读(180) 评论(0) 推荐(0)
摘要:Given a collection of numbers that might contain duplicates, return all possible unique permutations. For example, [1,1,2] have the following unique p 阅读全文
posted @ 2017-03-08 13:43 hellowOOOrld 阅读(201) 评论(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-03-08 11:00 hellowOOOrld 阅读(184) 评论(0) 推荐(0)
摘要:Given a set of distinct integers, nums, return all possible subsets. Note: The solution set must not contain duplicate subsets. For example, If nums = 阅读全文
posted @ 2017-03-07 17:24 hellowOOOrld 阅读(156) 评论(0) 推荐(0)
摘要:Follow up for "Unique Paths": Now consider if some obstacles are added to the grids. How many unique paths would there be? An obstacle and empty space 阅读全文
posted @ 2017-03-06 18:18 hellowOOOrld 阅读(164) 评论(0) 推荐(0)
摘要:A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). The robot can only move either down or right at any p 阅读全文
posted @ 2017-03-06 17:17 hellowOOOrld 阅读(179) 评论(0) 推荐(0)
摘要:Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path. 阅读全文
posted @ 2017-03-04 17:47 hellowOOOrld 阅读(145) 评论(0) 推荐(0)
摘要:You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping yo 阅读全文
posted @ 2017-03-04 15:03 hellowOOOrld 阅读(151) 评论(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 @ 2017-03-03 16:04 hellowOOOrld 阅读(144) 评论(0) 推荐(0)
摘要:Find the contiguous subarray within an array (containing at least one number) which has the largest sum. For example, given the array [-2,1,-3,4,-1,2, 阅读全文
posted @ 2017-03-03 13:32 hellowOOOrld 阅读(151) 评论(0) 推荐(0)
摘要:Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive. Example: Given nums = [-2, 0, 3, -5, 2, -1] sumR 阅读全文
posted @ 2017-03-03 10:01 hellowOOOrld 阅读(198) 评论(0) 推荐(0)
摘要:Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You may comple 阅读全文
posted @ 2017-03-02 20:29 hellowOOOrld 阅读(174) 评论(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 transaction 阅读全文
posted @ 2017-03-02 12:55 hellowOOOrld 阅读(240) 评论(0) 推荐(0)
摘要:Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum. For example: Given the below binary tree and su 阅读全文
posted @ 2017-03-02 10:08 hellowOOOrld 阅读(181) 评论(0) 推荐(0)
摘要:Given an unsorted array of integers, find the length of the longest consecutive elements sequence. For example, Given [100, 4, 200, 1, 3, 2], The long 阅读全文
posted @ 2017-03-01 17:22 hellowOOOrld 阅读(167) 评论(0) 推荐(0)