思路显然是暴力枚举. 但是两个问题: 1.当1的位数非常大时,模运算很费时间,会超时. 其实每次不用完全用'11111...'来%K,上一次的余数*10+1后再%K就行. 证明: 令f(n)=111111...(n个1); g(n)=f(n)%K 因为f(n)=f(n-1)*10+1 所以f(n)% ...
分类:
其他好文 时间:
2019-04-12 23:07:43
阅读次数:
242
Problem 5 Problem 5 2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder. What is the smallest po ...
分类:
其他好文 时间:
2019-04-02 17:06:58
阅读次数:
104
Given a binary search tree, write a function kthSmallest to find the kth smallest element in it. Note: You may assume k is always valid, 1 ≤ k ≤ BST's ...
分类:
其他好文 时间:
2019-03-31 14:07:00
阅读次数:
132
[TOC] 题目描述: 给定一个只包含小写字母的有序数组 和一个目标字母 ,寻找有序数组里面比目标字母大的最小字母。 数组里字母的顺序是循环的。举个例子,如果目标字母 并且有序数组为 ,则答案返回 。 示例: 注意: 1. 长度范围在 区间内。 2. 仅由小写字母组成,最少包含两个不同的字母。 3. ...
分类:
其他好文 时间:
2019-03-29 10:34:55
阅读次数:
164
Let's say we are given an array: We want to get K = 3 smallest items from the array and using Max heap data structure. So this is how to think about i ...
分类:
其他好文 时间:
2019-03-05 23:06:18
阅读次数:
188
Given a list of sorted characters letters containing only lowercase letters, and given a target letter target, find the smallest element in the list t ...
分类:
其他好文 时间:
2019-02-28 14:50:58
阅读次数:
179
1038 Recover the Smallest Number (30 分) Given a collection of number segments, you are supposed to recover the smallest number from them. For example, ...
分类:
其他好文 时间:
2019-02-26 13:24:23
阅读次数:
201
Problem: Given an array A, we may rotate it by a non-negative integer K so that the array becomes A[K], A[K+1], A{K+2], ... A[A.length - 1], A[0], A[1 ...
分类:
其他好文 时间:
2019-02-10 09:15:23
阅读次数:
168
Description First we define: (1) $lcm(a,b)$, the least common multiple of two integers $a$ and $b$, is the smallest positive integer that is divisible ...
分类:
其他好文 时间:
2019-02-09 12:05:06
阅读次数:
158