Skip to the editor
JSGroundwork
JSGroundwork handwritten · web dev
←Back to Advanced DP

Ready to read

JSJavaScript⑂Git◎Interview prepΣDSA in JSSDSystem Design
More topics15›
</>HTML{ }CSS⚛ReactNNext.jsNeNest.jsTSTypeScriptNoNode.js🐳DockerDBSQL & Databases✓Testing🔒Web Security☁Cloud & DevOps◈GraphQL◆Redis☸Kubernetes
☰‹›
Description
All topics›JavaScript›Advanced DP

Count Numbers With Strictly Increasing Digits

advancedlayer A1 · Advanced DP4 tests

Given a positive integer N, count how many integers in the range [1, N] have strictly increasing digits when written in base 10 — that is, every digit is larger than the digit before it.

  • 1, 7, 13 and 159 qualify
  • 11, 21 and 102 do not
  • Every one-digit number from 1 to 9 qualifies
  • N can be as large as 10^9, so counting one number at a time is out — walk the digits of N instead

Stuck?

All exercisesPlayground
1234567891011121314
loading the editor…

Nothing yet — hit Run and whatever you log shows up here.

Submit to see how you did.

⌘/Ctrl + Enter run⌘/Ctrl + S save⌘/Ctrl + / comment⌘/Ctrl + F find/replace⌘/Ctrl + D select next matchAlt + click multi-cursorTab indent · ⇧Tab outdentEsc leave fullscreen