### 题意 You have a total of n coins that you want to form in a staircase shape, where every k-th row must have exactly k coins. 你总共有 n 枚硬币,你需要将它们摆成一个阶梯形状,第 k 行就必须正好有 k 枚硬币。 Given n, find the total number of full staircase rows that can be fo...
阅读全文>>2018年4月30日 21:49 作者:nancy 分类:[LeetCode] 1369
### 题意 Given two non-negative integers num1 and num2 represented as string, return the sum of num1 and num2. 给定两个字符串形式的非负整数 num1 和 num2 ,计算它们的和。 ```python Note: 1.The length of both num1 and num2 is < 5100. 1.num1 和 num2 的长度都小于 5100。...
阅读全文>>2018年4月30日 14:48 作者:nancy 分类:[LeetCode] 1258
### 题意 Find the `n**th` digit of the infinite integer sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ... 在无限的整数序列 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ...中找到第 n 个数字。 Note: n is positive and will fit within the range of a 32-bit signed integer...
阅读全文>>2018年4月30日 13:44 作者:nancy 分类:[LeetCode] 1290
### 题意 Given a positive integer num, write a function which returns True if num is a perfect square else False. 给定一个正整数 num,编写一个函数,如果 num 是一个完全平方数,则返回 True,否则返回 False。 Note: Do not use any built-in library function such as sqrt. 注意:不要使用任...
阅读全文>>2018年4月28日 23:11 作者:nancy 分类:[LeetCode] 1254
### 题意 Given an integer, write a function to determine if it is a power of three. 给出一个整数,写一个函数来确定这个数是不是3的一个幂。 Follow up: Could you do it without using any loop / recursion? 你能不使用循环或者递归完成本题吗? ### 思路 求对数,然后乘方,判断得数是否相等 ```python # ...
阅读全文>>2018年4月28日 21:09 作者:nancy 分类:[LeetCode] 1351
### 题意 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 it includes another...
阅读全文>>2018年4月27日 22:02 作者:nancy 分类:[LeetCode] 1335
### 题意 Given a non-negative integer num, repeatedly add all its digits until the result has only one digit. 给一个非负整数 num,反复添加所有的数字,直到结果只有一个数字。 For example: Given num = 38, the process is like: 3 + 8 = 11, 1 + 1 = 2. Since 2 has only one d...
阅读全文>>2018年4月27日 21:58 作者:nancy 分类:[LeetCode] 1280
### 题意 Given a binary array, find the maximum number of consecutive 1s in this array. 给定一个二进制数组, 计算其中最大连续 1 的个数。 Example 1: ```python Input: [1,1,0,1,1,1] Output: 3 Explanation: The first two digits or the last three digits are consecut...
阅读全文>>2018年4月26日 21:33 作者:nancy 分类:[LeetCode] 1272
### 题意 Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once. 给定一个范围在 1 ≤ a[i] ≤ n ( n = 数组大小 ) 的 整型数组,数组中的元素一些出现了两次,另一些只出现一次。 Find all the elements of [1, n] inclusive that do...
阅读全文>>2018年4月26日 21:09 作者:nancy 分类:[LeetCode] 1326
### Python 函数参数传递 ```python a = 1 def fun(a): a = 2 fun(a) print(a) # 1 a = [] def fun(a): a.append(1) fun(a) print(a) # [1] ``` 所有的变量都可以理解是内存中一个对象的“引用”。 通过 id 来看引用 a 的内存地址可以比较理解: ```python a = 1 def fun(a): ...
阅读全文>>2018年4月26日 18:26 作者:nancy 分类:[Python] 1267
你还没有登录,请 或者