leetcode1012】的更多相关文章

Given a positive integer N, return the number of positive integers less than or equal to N that have at least 1 repeated digit. Example 1: Input: 20 Output: 1 Explanation: The only positive number (<= 20) with at least 1 repeated digit is 11. Example…
# given number n, see whether n has repeated number def has_repeated(n): str_n = str(n) return len(set(str_n)) != len(str_n) def permutation(n, k): prod = 1 for i in range(k): prod *= (n-i) return prod # calculate number of non-repeated n-digit numbe…