
Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.
History is littered with hundreds of conflicts over the future of a community, group, location or business that were "resolved" when one of the parties stepped ahead and destroyed what was there. With the original point of contention destroyed, the debates would fall to the wayside. Archive Team believes that by duplicated condemned data, the conversation and debate can continue, as well as the richness and insight gained by keeping the materials. Our projects have ranged in size from a single volunteer downloading the data to a small-but-critical site, to over 100 volunteers stepping forward to acquire terabytes of user-created data to save for future generations.
The main site for Archive Team is at archiveteam.org and contains up to the date information on various projects, manifestos, plans and walkthroughs.
This collection contains the output of many Archive Team projects, both ongoing and completed. Thanks to the generous providing of disk space by the Internet Archive, multi-terabyte datasets can be made available, as well as in use by the Wayback Machine, providing a path back to lost websites and work.
Our collection has grown to the point of having sub-collections for the type of data we acquire. If you are seeking to browse the contents of these collections, the Wayback Machine is the best first stop. Otherwise, you are free to dig into the stacks to see what you may find.
The Archive Team Panic Downloads are full pulldowns of currently extant websites, meant to serve as emergency backups for needed sites that are in danger of closing, or which will be missed dearly if suddenly lost due to hard drive crashes or server failures.
We have a sorted set of digits
D
, a non-empty subset of{'1','2','3','4','5','6','7','8','9'}
. (Note that'0'
is not included.)Now, we write numbers using these digits, using each digit as many times as we want. For example, if
D = {'1','3','5'}
, we may write numbers such as'13', '551', '1351315'
.Return the number of positive integers that can be written (using the digits of
D
) that are less than or equal toN
.Example 1:
Example 2:
Note:
D
is a subset of digits'1'-'9'
in sorted order.1 <= N <= 10^9
这道题给了我们一个有序字符串数组,里面是0到9之间的数(这里博主就纳闷了,既然只有一位数字,为啥不用 char 型,而要用 string 型),然后又给了一个整型数字N,问无限制次数使用D中的任意个数字,能组成多个不同的小于等于D的数字。先来分析例子1,当N为 100 时,所有的一位数和两位数都是可以的,既然可以重复使用数字,假设总共有n个数字,那么对于两位数来说,十位上和个位上分别都有n种可能,总共就是 n^2 种可能,对于一位数来说,总共n种可能。那么看到这里就可以归纳出当N总共有 len 位的话,我们就可以快速的求出不超过 len-1 位的所有情况综合,用个 for 循环,累加n的指数即可。然后就要来分析和数字N位数相等的组合,题目中的两个的例子的N都是1开始的,实际上N可以是任何数字,举个例子来说吧,假如 D={"1","3","5","7"},N=365,那么根据前面的分析,我们可以很快的算出所有的两位数和一位数的组合情况总数 4 + 4^2 = 20 个。现在要来分析三位数都有哪些组合,由于D数组是有序的,所以我们从开头遍历的话先取到的就是最小的,这时候有三种情况,小于,等于,和大于,每种的处理情况都有些许不同,这里就拿上面提到的例子进行一步一步的分析:
代码如下:
Github 同步地址:
#902
参考资料:
https://leetcode.com/problems/numbers-at-most-n-given-digit-set/
https://leetcode.com/problems/numbers-at-most-n-given-digit-set/discuss/225123/c%2B%2B100
https://leetcode.com/problems/numbers-at-most-n-given-digit-set/discuss/168439/C%2B%2B-O(logN)-Clear-code-with-explanation
LeetCode All in One 题目讲解汇总(持续更新中...)
The text was updated successfully, but these errors were encountered: