摘要:
每种task都有冷却时间,比如task1执行后,要经过interval时间后才能再次执行,求总共所需时间。用HashMap保存每一个task的下一次可以开始执行的最早时间 1 package TaskSchedule; 2 import java.util.*; 3 4 public class ...
阅读全文
posted @ 2016-01-11 07:09
neverlandly
阅读(1637)
推荐(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
阅读(267)
推荐(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
阅读(5863)
推荐(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
阅读(1323)
推荐(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
阅读(2056)
推荐(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
阅读(1018)
推荐(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
阅读(573)
推荐(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
阅读(714)
推荐(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
阅读(504)
推荐(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
阅读(7427)
推荐(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
阅读(1424)
推荐(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
阅读(467)
推荐(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
阅读(561)
推荐(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
阅读(496)
推荐(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
阅读(2974)
推荐(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
阅读(505)
推荐(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
阅读(3228)
推荐(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
阅读(953)
推荐(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
阅读(535)
推荐(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
阅读(824)
推荐(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
阅读(389)
推荐(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
阅读(418)
推荐(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
阅读(611)
推荐(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
阅读(810)
推荐(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
阅读(5490)
推荐(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
阅读(369)
推荐(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
阅读(875)
推荐(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
阅读(2558)
推荐(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
阅读(334)
推荐(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
阅读(1490)
推荐(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
阅读(2909)
推荐(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
阅读(3763)
推荐(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
阅读(330)
推荐(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
阅读(239)
推荐(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
阅读(946)
推荐(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
阅读(431)
推荐(0)
摘要:
Be careful, when calculate B, you should exclude A's cases
阅读全文
posted @ 2015-12-29 04:52
neverlandly
阅读(340)
推荐(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
阅读(382)
推荐(0)