357. Count Numbers with Unique Digits 数学 找规律
来源:互联网 发布:不要网络的单机游戏 编辑:程序博客网 时间:2024/06/09 21:47
Given a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x < 10n.
Example:
Given n = 2, return 91. (The answer should be the total numbers in the range of 0 ≤ x < 100, excluding [11,22,33,44,55,66,77,88,99]
)
Credits:
Special thanks to @memoryless for adding this problem and creating all test cases.
class Solution {public: int countNumbersWithUniqueDigits(int n) { if(n==0) return 1; if(n==1) return 10; int res=10; int temp=81; int i=8; while(n>1) { res+=temp; temp*=i--; n--; } return res; }};
阅读全文
0 0
- 357. Count Numbers with Unique Digits 数学 找规律
- 【LeetCode】357. Count Numbers with Unique Digits
- 357. Count Numbers with Unique Digits
- LeetCode 357. Count Numbers with Unique Digits
- [leetcode] 357. Count Numbers with Unique Digits
- 357. Count Numbers with Unique Digits
- 【LeetCode】357. Count Numbers with Unique Digits
- leetcode 357. Count Numbers with Unique Digits
- leetcode 357. Count Numbers with Unique Digits
- leetcode.357. Count Numbers with Unique Digits
- 357. Count Numbers with Unique Digits
- 357. Count Numbers with Unique Digits
- 357. Count Numbers with Unique Digits
- 357. Count Numbers with Unique Digits
- 357. Count Numbers with Unique Digits
- 357. Count Numbers with Unique Digits
- 357. Count Numbers with Unique Digits
- 357. Count Numbers with Unique Digits
- 2017 ACM/ICPC Asia Regional Shenyang Online//string string string(后缀自动机,未学习)
- 对第一,二,三,BC,四范式的理解
- oracle+110个常用的函数
- 浅谈web缓存
- SpringMVC-Mybatis-Memcached整合案例
- 357. Count Numbers with Unique Digits 数学 找规律
- 反转句子
- liunx上的MySQL卸载
- 在Java中使用正则表达式温习笔记
- java操作Excel
- javaSE-Day5 引用传递(数据表与java类的转换)
- PAT-1063 Set Similarity (set集合)
- MySQL和Oracle的group by的异同
- Lua爬坑手记