源码之家

  • 首页
  • 文章
  • 问答
  • 下载
您的位置: 首页  >  文章  >  Leetcode 357. Count Numbers with Unique Digits

Leetcode 357. Count Numbers with Unique Digits

分类: 文章 • 2024-06-06 23:34:23

文章作者:Tyan
博客:noahsnail.com  |  ****  |  简书

1. Description

Leetcode 357. Count Numbers with Unique Digits

2. Solution

class Solution {
public:
    int countNumbersWithUniqueDigits(int n) {
        int total = 1;
        for(int i = 0; i < n; i++) {
            int count = 9;
            for(int j = 1; j <= i; j++) {
                count *= (10 - j);
            }
            total += count;
        }
        return total;
    }
};

Reference

  1. https://leetcode.com/problems/count-numbers-with-unique-digits/description/

相关推荐

  • Leetcode 357. Count Numbers with Unique Digits
  • 算法分析与设计第七次作业(leetcode 中 Count of Smaller Numbers After Self 和 Count of Range Sum 题解)
  • 算法分析与设计第七次作业(leetcode 中 Count of Smaller Numbers After Self 和 Count of Range Sum 题解)
  • leetcode 443: String Compression,357: Count Numbers with Unique Digits
  • leetCode 357. Count Numbers with Unique Digits | Dynamic Programming | Medium
  • leetCode 357. Count Numbers with Unique Digits | Dynamic Programming | Medium
  • jQuery基本用法
  • bootstrap-validator 验证一个标签同时验证另一个指定标签
    网站免责声明 网站地图 最新文章 用户隐私 版权申明
本站所有数据收集于网络,如果侵犯到您的权益,请联系网站进行下架处理。   

Copyright © 2018-2021   Powered By 源码之家    备案号:   粤ICP备20058927号