![](https://img-blog.csdnimg.cn/20201014180756926.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Math
Arcome
这个作者很懒,什么都没留下…
展开
-
LeetCode #279 - Perfect Squares - Medium
ProblemGiven a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, ...) which sum to n.Examplegiven n = 12, return 3 because 12 = 4 + 4 + 4; given n =原创 2016-12-11 11:53:24 · 368 阅读 · 0 评论 -
LeetCode #357 - Count Numbers with Unique Digits - Medium
ProblemGiven a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x < 10n.Hints:A direct way is to use the backtracking approach.Backtracking should contains three states whi原创 2016-12-19 18:56:38 · 282 阅读 · 0 评论 -
LeetCode #9 - Palindrome Number - Easy
ProblemDetermine whether an integer is a palindrome. Do this without extra space.Some hints:Could negative integers be palindromes? (ie, -1)If you are thinking of converting the integer to string, not原创 2016-12-10 11:03:49 · 451 阅读 · 0 评论 -
LeetCode #231 - Power of Two - Easy
ProblemGiven an integer, write a function to determine if it is a power of two.ExampleInput: 2Output: trueAlgorithm整理一下题意:给定一个整数,判断其是否是2的幂。简单判断即可。注意特殊情况,如负数,0,1。代码如下。class Solution {public: boo原创 2016-12-07 20:39:16 · 286 阅读 · 0 评论 -
LeetCode #319 - Bulb Switcher - Medium
ProblemThere 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 third bulb (turning on if it’s off or turn原创 2016-12-07 20:34:04 · 487 阅读 · 0 评论 -
LeetCode #13 - Roman to Integer - Easy
ProblemGiven a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.ExampleInput: IOutput: 1Algorithm整理一下题意:给定一个罗马数字,要求返回其整数值解题首先要了解罗马数字与阿拉伯数字的对应规则。 基本原创 2016-12-07 19:46:46 · 430 阅读 · 0 评论 -
LeetCode #268 - Missing Number - Medium
ProblemGiven an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missing from the array.Note:Your algorithm should run in linear runtime complexity. Could yo原创 2016-12-06 15:29:10 · 294 阅读 · 0 评论 -
LeetCode #171 - Excel Sheet Column Number - Easy
ProblemRelated to question Excel Sheet Column TitleGiven a column title as appear in an Excel sheet, return its corresponding column number.ExampleA -> 1B -> 2C -> 3...Z -> 26AA -> 27AB -> 28 A原创 2016-12-06 12:05:52 · 391 阅读 · 0 评论 -
LeetCode #258 - Add Digits -Easy
ProblemGiven a non-negative integer num, repeatedly add all its digits until the result has only one digit.Hints:A naive implementation of the above process is trivial. Could you come up with other m原创 2016-12-06 11:59:48 · 343 阅读 · 0 评论 -
LeetCode #168 - Excel Sheet Column Title - Easy
ProblemGiven a positive integer, return its corresponding column title as appear in an Excel sheet.Example1 -> A2 -> B3 -> C...26 -> Z27 -> AA28 -> AB Algorithm整理一下题意:给定一个正整数,要求返回其在Excel中代表的列号。原创 2016-12-14 21:20:29 · 338 阅读 · 0 评论 -
LeetCode #7 - Reverse Integer - Easy
ProblemReverse digits of an integer.ExampleExample1: x = 123, return 321Example2: x = -123, return -321Algorithm整理一下题意:给定一个整数,要求返回其数字倒序后的数。此题比较简单,直接利用除10加模10的方法即可得到倒序。注意当给定的整数大于INT_MAX和小于INT_MIN的情况。原创 2016-12-14 21:03:53 · 268 阅读 · 0 评论 -
LeetCode #396 - Rotate Function - Easy
ProblemGiven an array of integers A and let n to be its length.Assume Bk to be an array obtained by rotating the array A k positions clock-wise, we define a "rotation function" F on A as follow:F(k) =原创 2016-12-14 20:58:25 · 300 阅读 · 0 评论 -
LeetCode #223 - Rectangle Area - Easy
ProblemFind the total area covered by two rectilinear rectangles in a 2D plane.Each rectangle is defined by its bottom left corner and top right corner as shown in the figure.Assume that the total area原创 2016-12-14 17:41:07 · 442 阅读 · 0 评论 -
LeetCode #89 - Gray Code - Medium
ProblemThe gray code is a binary numeral system where two successive values differ in only one bit.Given a non-negative integer n representing the total number of bits in the code, print the sequence o原创 2016-12-20 08:07:58 · 365 阅读 · 0 评论