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. 这是100年后火星的未来,到处都是CBD!

    ​火星是个荒漠之地,尽管如此,最近几十年人类一直准备登录火星,然后殖民火星.随着科技的迅猛发展,感觉火星离我们越来越近了.不过,人类如何在火星上生存下去,这一直是科学家们最热衷的话题. ​意大利建筑师 ...

  2. Android实习生 —— 屏幕适配及布局优化

    为什么要进行屏幕适配.对哪些设备进行适配?在近几年的发展当中,安卓设备数量逐渐增长,由于安卓设备的开放性,导致安卓设备的屏幕尺寸大小碎片化极为严重.从[友盟+]2016年手机生态发展报告H1中看截止1 ...

  3. Go基础学习(二)

    数组[array] 数组定义[定义后长度不可变] 12 symbol := [...]string{USD: "$", EUR: "€", GBP: " ...

  4. 【自己的下载平台】搭建aria2网站

    前言 本文章将带你搭建一个自己的服务器下载平台:aria2,它的用途是什么? 下载用途 百度网盘 普通文件 迅雷种子 等等 准备工具 服务器连接软件xshell或者putty 一台服务器 安装宝塔面板 ...

  5. C++走向远洋——48(项目一1、复数类中的运算符重载、类的成员函数)

    */ * Copyright (c) 2016,烟台大学计算机与控制工程学院 * All rights reserved. * 文件名:text.cpp * 作者:常轩 * 微信公众号:Worldhe ...

  6. marquee横向无缝滚动无js

    <!DOCTYPE html><html><head><meta charset="utf-8"> <title>< ...

  7. 关于Markdown下无法使用表格的解决方案

    关于Markdown下无法使用表格的解决方案 写表格,出现如下场景 解决方法.点击左下角M的表示,切换到extra模式 打开了新世界.如果不能点击,估计是你没有激活pro的权限,百度下就可以了. 或者 ...

  8. 大厂面试官问你META-INF/spring.factories要怎么实现自动扫描、自动装配?

    大厂面试官问你META-INF/spring.factories要怎么实现自动扫描.自动装配?   很多程序员想面试进互联网大厂,但是也有很多人不知道进入大厂需要具备哪些条件,以及面试官会问哪些问题, ...

  9. XXE学习(一)——XML基础

    XXE学习(一)——xml基础 一.XML简介 XML 指可扩展标记语言(EXtensible Markup Language) XML 是一种标记语言,很类似 HTML XML 的设计宗旨是传输数据 ...

  10. windows下tensorflow/objectdetection API环境搭建(基于tensorflow1.14和python3.6)

    此前就听闻室友说tensorflow在windows下坑很多,这次终于亲身领会到了.以下是参考网上大佬的教程以及自己的踩坑史总结出的有效步骤(亲测有效) 1.下载objectdetection所在的m ...