I have trained my algorithm on leetcode a period of time.
Today, I will explain my solution about Minimum Height Trees.
My solution beat ~95% against others but it is hard to explain what is I do.
Please allow me to introduce the solution from easy to hard. If you only need the
last solution, jump to继续阅读 »
Solution & Estimations:
Current solution is to 1.) let Swarm launch tasks by Mesos 2.) for the other API, let Swarm send request to docker engine directly (red arrow)继续阅读 »
Question
Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as the Hamming weight).
For example, the 32-bit integer ’11' has binary representation 00000000000000000000000000001011, so the function should return 3.
解说
这道题的意思是统计32位整数二进制格式下的‘1’的个数。
more
Solution
rig继续阅读 »
Question
Given an array of integers, return indices of the two numbers such that they add up to a specific target.
You may assume that each input would have exactly one solution.
Example:
Given nums = [2, 7, 11, 15], target = 9,
Because nums[0] + nums[1] = 2 + 7 = 9,
return [0, 1].
UPDATE (2016/2/13):
The return forma继续阅读 »
blueprint简介和生命周期
简单来说,blueprint主要阐述了一些想法,例如新功能或组件,跟踪相关开发人员完成的进度,通常用来维护新特性实现的完整记录。从第一个想法到完整实现,有序管理版本发布。OpenStack使用launchpad作为协作开发平台,每个项目都有自己页面。与Bug的区别:A bug is a description of a problem, and a blueprint is a description of a solution。
对于一个bp来讲,标题和描述是必要的,但对于复杂的流程或功能,最好准备一个wiki文档,并将链接贴在描述区。同时,最好指定该bp的milestone(即版本计划),这继续阅读 »
231. Power of Two
Question
Given an integer, write a function to determine if it is a power of two.
Solution
Approach #1 (count the number of 1) [Accepted]
Algorithm
Integer is a power of two means only one bit of n is '1', for example, 100 is 2^2=4 while 110 is 2^2+2^1=6.继续阅读 »