本文主要是介绍Java | Leetcode Java题解之第357题统计各位数字都不同的数字个数,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
题目:
题解:
class Solution {public int countNumbersWithUniqueDigits(int n) {if (n == 0) {return 1;}if (n == 1) {return 10;}int res = 10, cur = 9;for (int i = 0; i < n - 1; i++) {cur *= 9 - i;res += cur;}return res;}
}
这篇关于Java | Leetcode Java题解之第357题统计各位数字都不同的数字个数的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!