面试算法
Leezy__
这个作者很懒,什么都没留下…
展开
-
Majority Element
题目来自于: LeetCode 169.Majority Element 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 t原创 2016-01-22 00:34:00 · 222 阅读 · 0 评论 -
Ugly Number
/** * @param {number} num * @return {boolean} */ var isUgly = function(num) { if(num <= 0){ return false; } if(num == 1){ return true; } while(num % 2 === 0){原创 2016-01-22 09:48:49 · 197 阅读 · 0 评论 -
Power of Two
题目来自于: LeetCode 231.power of two Given an integer, write a function to determine if it is a power of two. 思路:一个数如果不是2^n,那么对这个数反复做除二操作最后的余数一定是1. language-javascript /** * @param {原创 2016-01-22 20:12:48 · 189 阅读 · 0 评论 -
Climbing Stairs
题目来自于: LeetCode 70.Climbing Stairs 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原创 2016-01-23 00:27:12 · 196 阅读 · 0 评论 -
Valid Anagram
题目来自于: LeetCode 242 Valid Anagram Given two strings s and t, write a function to determine if t is an anagram of s. For example, s = "anagram", t = "nagaram", return true. s = "rat", t = "原创 2016-01-14 18:14:54 · 246 阅读 · 0 评论