摘要:        
每种task都有冷却时间,比如task1执行后,要经过interval时间后才能再次执行,求总共所需时间。用HashMap保存每一个task的下一次可以开始执行的最早时间 1 package TaskSchedule; 2 import java.util.*; 3 4 public class ...    
阅读全文
 
 
        posted @ 2016-01-11 07:09
neverlandly
阅读(1633)
推荐(0)
            
        
        
        posted @ 2016-01-11 04:40
neverlandly
阅读(11)
推荐(0)
    
 
		
    
        
        
摘要:        
Given an array of integers, find the subarray with smallest sum.Return the sum of the subarray.Have you met this question in a real interview? YesExam...    
阅读全文
 
 
        posted @ 2016-01-09 06:09
neverlandly
阅读(262)
推荐(0)
            
        
        
摘要:        
Given an integer, write a function to determine if it is a power of three. Follow up: Could you do it without using any loop / recursion? Recursion: 1    
阅读全文
 
 
        posted @ 2016-01-09 04:32
neverlandly
阅读(5857)
推荐(0)
    
 
		
    
        
        
摘要:        
Given a permutation which may contain repeated numbers, find its index in all the permutations of these numbers, which are ordered in lexicographical ...    
阅读全文
 
 
        posted @ 2016-01-06 09:11
neverlandly
阅读(1315)
推荐(0)
            
        
        
摘要:        
Given a permutation which contains no repeated number, find its index in all the permutations of these numbers, which are ordered in lexicographical o...    
阅读全文
 
 
        posted @ 2016-01-06 07:56
neverlandly
阅读(2053)
推荐(0)
            
        
        
摘要:        
Given n pieces of wood with length L[i] (integer array). Cut them into small pieces to guarantee you could have equal or more than k pieces with the s...    
阅读全文
 
 
        posted @ 2016-01-06 05:59
neverlandly
阅读(1015)
推荐(0)
            
        
        
摘要:        
Given two 32-bit numbers, N and M, and two bit positions, i and j. Write a method to set all bits between i and j in N equal to M (e g , M becomes a s...    
阅读全文
 
 
        posted @ 2016-01-06 05:20
neverlandly
阅读(567)
推荐(0)
            
        
        
摘要:        
Given a directed graph, design an algorithm to find out whether there is a route between two nodes.Have you met this question in a real interview? Yes...    
阅读全文
 
 
        posted @ 2016-01-06 04:58
neverlandly
阅读(710)
推荐(0)
            
        
        
摘要:        
Determine the number of bits required to flip if you want to convert integer n to integer m.Have you met this question in a real interview? YesExample...    
阅读全文
 
 
        posted @ 2016-01-06 04:34
neverlandly
阅读(501)
推荐(0)
            
        
        
摘要:        
Given an array nums and a target value k, find the maximum length of a subarray that sums to k. If there isn't one, return 0 instead.Example 1:Given n...    
阅读全文
 
 
        posted @ 2016-01-06 04:20
neverlandly
阅读(7425)
推荐(0)
    
 
		
    
        
        
摘要:        
Given an integer array, find a subarray with sum closest to zero. Return the indexes of the first number and last number.Have you met this question in...    
阅读全文
 
 
        posted @ 2016-01-05 11:39
neverlandly
阅读(1419)
推荐(0)
            
        
        
摘要:        
iven a root of Binary Search Tree with unique value for each node. Remove the node with given value. If there is no such a node with given value in t...    
阅读全文
 
 
        posted @ 2016-01-05 07:36
neverlandly
阅读(466)
推荐(0)
            
        
        
摘要:        
Given an array of integers and a number k, the majority number is the number that occurs more than 1/k of the size of the array.Find it.Have you met t...    
阅读全文
 
 
        posted @ 2016-01-05 05:57
neverlandly
阅读(560)
推荐(0)
    
 
		
    
        
        
摘要:        
Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive.The update(i, val) function modifies nums by upda...    
阅读全文
 
 
        posted @ 2016-01-02 13:48
neverlandly
阅读(493)
推荐(0)
            
        
        
摘要:        
Given two arrays of length m and n with digits 0-9 representing two numbers. Create the maximum number of length k 0 && n-i-1>=count-j && res[j-1]arr2...    
阅读全文
 
 
        posted @ 2016-01-02 10:17
neverlandly
阅读(2969)
推荐(0)
            
        
        
摘要:        
Given a string array words, find the maximum value of length(word[i]) * length(word[j]) where the two words do not share common letters. You may assum...    
阅读全文
 
 
        posted @ 2016-01-02 07:13
neverlandly
阅读(501)
推荐(0)
            
        
        
摘要:        
Adopted approach: start from each building, try to reach all 0. Alternertive approch can be start from each 0, try to reach all buildings. Which is wa    
阅读全文
 
 
        posted @ 2016-01-02 05:53
neverlandly
阅读(3222)
推荐(0)
            
        
        
摘要:        
Given a string which contains only lowercase letters, remove duplicate letters so that every letter appear once and only once. You must make sure your...    
阅读全文
 
 
        posted @ 2016-01-02 02:18
neverlandly
阅读(952)
推荐(0)
    
 
		
    
        
        
摘要:        
You are given an integer array nums and you have to return a new counts array. The counts array has the property where counts[i] is the number of smal    
阅读全文
 
 
        posted @ 2016-01-01 14:26
neverlandly
阅读(533)
推荐(0)
            
        
        
摘要:        
Given a binary tree, return the vertical order traversal of its nodes' values. (ie, from top to bottom, column by column).If two nodes are in the same...    
阅读全文
 
 
        posted @ 2016-01-01 11:44
neverlandly
阅读(819)
推荐(0)
            
        
        
摘要:        
There are n bulbs that are initially off. You first turn on all the bulbs. Then, you turn off every second bulb. On the third round, you toggle every ...    
阅读全文
 
 
        posted @ 2016-01-01 07:53
neverlandly
阅读(386)
推荐(0)
            
        
        
摘要:        
Write a program to find the nth super ugly number.Super ugly numbers are positive numbers whose all prime factors are in the given prime list primes o...    
阅读全文
 
 
        posted @ 2016-01-01 07:21
neverlandly
阅读(412)
推荐(0)
            
        
        
摘要:        
Given n balloons, indexed from 0 to n-1. Each balloon is painted with a number on it represented by array nums. You are asked to burst all the balloon...    
阅读全文
 
 
        posted @ 2016-01-01 06:37
neverlandly
阅读(608)
推荐(0)
            
        
        
摘要:        
Hint: build graph first, also buil indegree array, then find leaf and remove them among their neighbors, level by level. Until left less 2 nodes 这道题跟一    
阅读全文
 
 
        posted @ 2016-01-01 02:39
neverlandly
阅读(806)
推荐(0)
            
        
        
摘要:        
Write a function to generate the generalized abbreviations of a word.Example:Given word = "word", return the following list (order does not matter):["...    
阅读全文
 
 
        posted @ 2016-01-01 01:07
neverlandly
阅读(5486)
推荐(0)
    
 
		
    
        
        
摘要:        
You are given coins of different denominations and a total amount of money amount. Write a function to compute the fewest number of coins that you nee...    
阅读全文
 
 
        posted @ 2015-12-31 14:07
neverlandly
阅读(366)
推荐(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 complet...    
阅读全文
 
 
        posted @ 2015-12-31 13:15
neverlandly
阅读(870)
推荐(0)
            
        
        
摘要:        
Given two sparse matrices A and B, return the result of AB.You may assume that A's column number is equal to B's row number.Example:A = [ [ 1, 0, 0],...    
阅读全文
 
 
        posted @ 2015-12-31 07:57
neverlandly
阅读(2555)
推荐(0)
            
        
        
摘要:        
参考http://segmentfault.com/a/1190000003797204 and http://blog.csdn.net/u013027996/article/details/48713751 深度优先搜索 复杂度 时间 O(N^2) 空间 O(N) 思路 因为要输出所有可能的情况    
阅读全文
 
 
        posted @ 2015-12-31 07:13
neverlandly
阅读(331)
推荐(0)
            
        
        
摘要:        
Remove the minimum number of invalid parentheses in order to make the input string valid. Return all possible results. Note: The input string may cont    
阅读全文
 
 
        posted @ 2015-12-31 02:34
neverlandly
阅读(1484)
推荐(0)
    
 
		
    
        
        
摘要:        
Given n nodes labeled from 0 to n - 1 and a list of undirected edges (each edge is a pair of nodes), write a function to find the number of connected ...    
阅读全文
 
 
        posted @ 2015-12-30 13:04
neverlandly
阅读(2906)
推荐(0)
            
        
        
摘要:        
Union Find Princeton's lecture note on Union Find in Algorithms and Data Structures It is a well organized note with clear illustration describing fro    
阅读全文
 
 
        posted @ 2015-12-30 08:09
neverlandly
阅读(3758)
推荐(0)
            
        
        
摘要:        
Additive number is a string whose digits can form additive sequence. A valid additive sequence should contain at least three numbers. Except for the f    
阅读全文
 
 
        posted @ 2015-12-30 05:13
neverlandly
阅读(324)
推荐(0)
    
 
		
    
        
        
        posted @ 2015-12-29 09:25
neverlandly
阅读(323)
推荐(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 @ 2015-12-29 08:56
neverlandly
阅读(231)
推荐(0)
            
        
        
摘要:        
An image is represented by a binary matrix with 0 as a white pixel and 1 as a black pixel. The black pixels are connected, i.e., there is only one bla    
阅读全文
 
 
        posted @ 2015-12-29 08:28
neverlandly
阅读(943)
推荐(0)
            
        
        
摘要:        
讲解一: 用一个数组来存 the smallest tail of all increasing subsequences with length i+1 in tails[i]. For example, say we have nums = [4,5,6,3], then all the ava    
阅读全文
 
 
        posted @ 2015-12-29 06:07
neverlandly
阅读(429)
推荐(0)
            
        
        
摘要:        
Be careful, when calculate B, you should exclude A's cases    
阅读全文
 
 
        posted @ 2015-12-29 04:52
neverlandly
阅读(338)
推荐(0)
            
        
        
摘要:        
Referring this post: https://leetcode.com/problems/serialize-and-deserialize-binary-tree/discuss/74253/Easy-to-understand-Java-Solution But instead us    
阅读全文
 
 
        posted @ 2015-12-29 03:16
neverlandly
阅读(378)
推荐(0)