Math
文章平均质量分 70
dyllanzhou
这个作者很懒,什么都没留下…
展开
-
[Leetcode]Sqrt(x)
Implement int sqrt(int x). Compute and return the square root of x. class Solution { public: /*algorithm: binary search use x/m < m instead of x < m*m to prevent overflow */ int原创 2015-11-05 22:01:28 · 237 阅读 · 0 评论 -
[Leetcode]Power of Three
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? Credits: Special thanks to @dietpepsi for adding this pr原创 2016-06-23 11:14:00 · 263 阅读 · 0 评论 -
[Leetcode]Power of Four
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 false. Follow up: Could you solve it without loop原创 2016-06-24 15:31:12 · 282 阅读 · 0 评论 -
[Leetcode]Divide Two Integers
Divide two integers without using multiplication, division and mod operator. If it is overflow, return MAX_INT. class Solution { public: /*algorithm binary search */ int bSearch(lon原创 2015-11-19 15:11:26 · 254 阅读 · 0 评论 -
[Leetcode]Multiply Strings
Given two numbers represented as strings, return multiplication of the numbers as a string. Note: The numbers can be arbitrarily large and are non-negative. class Solution { public: /*algorithm原创 2015-11-13 15:14:15 · 210 阅读 · 0 评论 -
[Leetcode]Perfect Squares
Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, ...) which sum to n. For example, given n = 12, return 3 because 12 = 4 + 4 + 4; given n = 13,原创 2015-09-10 18:00:28 · 466 阅读 · 0 评论 -
[Leetcode]Missing Number
Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missing from the array. For example, Given nums = [0, 1, 3] return 2. Note: Your algorithm should run原创 2015-09-23 16:57:31 · 300 阅读 · 0 评论 -
[Leetcode] Integer to Roman
Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range from 1 to 3999. /*roman background Symbol Value I 1 V 5 X 10 L 50 C原创 2015-09-22 19:09:55 · 312 阅读 · 0 评论 -
[Leetcode]Pow(x, n)
Implement pow(x, n). Have you met this question in a real interview? class Solution { public: /*algorithm: divde and conqure */ double myPow(double x,原创 2015-10-26 20:31:41 · 287 阅读 · 0 评论 -
[Leetcode]Ugly Number II
Write a program to find the n-th ugly number. Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 1, 2, 3, 4, 5, 6, 8, 9, 10, 12 is the sequence of the first 10原创 2015-11-10 23:10:32 · 245 阅读 · 0 评论 -
[Leetcode]Permutation Sequence
The set [1,2,3,…,n] contains a total of n! unique permutations. By listing and labeling all of the permutations in order, We get the following sequence (ie, for n = 3): "123""132""213""231""312""原创 2015-11-09 22:49:19 · 260 阅读 · 0 评论 -
[Leetcode]Ugly Number
Write a program to check whether a given number is an ugly number. Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 6, 8 are ugly while 14 is not ugly since i原创 2015-11-09 22:58:39 · 191 阅读 · 0 评论 -
[Leetcode]Count Numbers with Unique Digits
Given a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x n. Example: Given n = 2, return 91. (The answer should be the total numbers in the range of 0 ≤ x < 100, excludin原创 2016-09-05 13:52:37 · 423 阅读 · 0 评论