摘要: Given an integer, write a function to determine if it is a power of two. 2的幂数二进制只有一个1 阅读全文
posted @ 2016-05-11 22:16 米开朗菠萝 阅读(107) 评论(0) 推荐(0)
摘要: You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you cl 阅读全文
posted @ 2016-05-11 22:10 米开朗菠萝 阅读(169) 评论(0) 推荐(0)
摘要: Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times. You may assume that the 阅读全文
posted @ 2016-05-11 21:40 米开朗菠萝 阅读(130) 评论(0) 推荐(0)
摘要: Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements. For example, giv 阅读全文
posted @ 2016-05-11 21:17 米开朗菠萝 阅读(135) 评论(0) 推荐(0)
摘要: Given a non-negative integer num, repeatedly add all its digits until the result has only one digit. For example: Given num = 38, the process is like: 阅读全文
posted @ 2016-05-11 20:49 米开朗菠萝 阅读(127) 评论(0) 推荐(0)
摘要: You are playing the following Nim Game with your friend: There is a heap of stones on the table, each time one of you take turns to remove 1 to 3 ston 阅读全文
posted @ 2016-05-11 20:15 米开朗菠萝 阅读(166) 评论(0) 推荐(0)
摘要: Given an integer (signed 32 bits), write a function to check whether it is a power of 4. Example:Given num = 16, return true. Given num = 5, return fa 阅读全文
posted @ 2016-05-11 08:41 米开朗菠萝 阅读(133) 评论(0) 推荐(0)