2020-01-03 12:01:46

问题描述

问题求解

确实可以当作数学题去做,但是要分类讨论什么的还是有点麻烦的。

这个时候万能的dfs上场了,直接暴力检索,真的太强了。

    int res = 0;
public int numDupDigitsAtMostN(int N) {
dfs(0, 0, N);
return N - res + 1;
} private void dfs(long curr, int used, int N) {
if (curr > N) return;
res += 1;
for (int i = 0; i < 10; i++) {
if (i == 0 && used == 0) continue;
if ((used & (1 << i)) > 0) continue;
dfs(curr * 10 + i, used | (1 << i), N);
}
}

  

Numbers With Repeated Digits的更多相关文章

  1. leetcode_1015. Numbers With Repeated Digits

    https://leetcode.com/problems/numbers-with-repeated-digits/ 与leetcode_357. Count Numbers with Unique ...

  2. 解题报告-1012. Numbers With Repeated Digits

    Given a positive integer N, return the number of positive integers less than or equal to N that have ...

  3. 【leetcode】1012. Numbers With Repeated Digits

    题目如下: Given a positive integer N, return the number of positive integers less than or equal to N tha ...

  4. [LeetCode] Count Numbers with Unique Digits 计算各位不相同的数字个数

    Given a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x < 10n. Examp ...

  5. Count Numbers with Unique Digits

    Given a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x < 10n. Examp ...

  6. Leetcode: Count Numbers with Unique Digits

    Given a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x < 10n. Examp ...

  7. 357. Count Numbers with Unique Digits

    Given a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x < 10n. Examp ...

  8. 【Leetcode】357. Count Numbers with Unique Digits

    题目描述: Given a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x < 10n. ...

  9. [leetcode-357-Count Numbers with Unique Digits]

    Given a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x < 10n. Examp ...

随机推荐

  1. DZNEmptyDataSet的使用

    DZNEmptyDataSet是外国友人写的开源项目,github地址(具体的使用以及Demo,点击进入github主页),简单介绍下DZNEmptyDataSet的使用方法. 对于iOS开发者来说, ...

  2. frp端口映射穿透内网

    前言 frp 是一个高性能的反向代理应用,可以轻松地进行内网穿透,对外网提供服务,支持 TCP.UDP.HTTP.HTTPS 等协议类型,并且 web 服务支持根据域名进行路由转发. Github: ...

  3. 百度地图API:使用百度定位

    准备工作: 1.申请百度地图API 2.下载百度地图的SDK 3.将SDK包中的BaiduLBS_Android.jar文件放到,项目里的app/libs里面 4.在src/main目录下创建一个名为 ...

  4. python中使用paramiko模块并实现远程连接服务器执行上传下载

    paramiko模块 paramiko是用python语言写的一个模块,遵循SSH2协议,支持以加密和认证的方式,进行远程服务器的连接. 因此,如果需要使用SSH从一个平台连接到另外一个平台,进行一系 ...

  5. tp5.1 请求时间格式化

    当前时间:{$Request.time|date='Y-m-d H:i:s'} 注意database.php的配置!记录一下!

  6. 二叉堆的BuildHeap操作

    优先队列(二叉堆)BuildHeap操作 \(BuildHeap(H)\)操作把\(N\)个关键字作为输入并把它们放入空堆中.显然,这可以使用\(N\)个相继的\(Insert\)操作来完成.由于每个 ...

  7. 前端面试题-<!DOCTYPE>

    现在的各种前端开发工具都足够强大,支持插入模板代码,也就导致我们往往会忽略已经自动生成的代码,而代码的第一行 DOCTYPE 声明,就是最容易忽略的部分. 一.DOCTYPE DOCTYPE 是 do ...

  8. VS2017配置opencv-4.2.0详细步骤

    VS2017配置opencv-4.2.0详细步骤   1.下载opencv的安装包并解压.下载网址https://sourceforge.net/projects/opencvlibrary/ 图1 ...

  9. 2019-2020-2 20175226 王鹏雲 网络对抗技术 Exp2 后门原理与实践

    2019-2020-2 20175226 王鹏雲 网络对抗技术 Exp2 后门原理与实践 实验内容 使用netcat获取主机操作Shell,cron启动: 使用socat获取主机操作Shell, 任务 ...

  10. 将root用户权限赋予普通用户

    将root用户权限赋予普通用户 普通用户想要拥有root用户的权限,必须修改/etc/sudoers文件 ,还必须使用visudo命令修改.一是因为这个命令能防止多个用户同时修改这个文件,二是能进行有 ...