Skip to content
We areTOP 1%

Number of Digit One

HardLeetCodeAdvanced DP (Bitmask, Digit, Interval)
Solve on LeetCode(opens in a new tab)
Track your progress
First attempt
Re-solve after a few days
Final pass before interviews
Approach hintTry it first, then reveal

Count contributions position by position: for each power of ten, the digits to the left and to the right of that position decide how many times a 1 appears there. A digit DP carrying the number of ones so far also works.

More in Advanced DP (Bitmask, Digit, Interval)

Advanced DP (Bitmask, Digit, Interval) questions
#ProblemPlatformDifficultyOpen1st1st Visit2nd2nd VisitRevRevise
1Kefa and DishesCodeforcesHard 1800Solve Kefa and Dishes on Codeforces (opens in a new tab)
2Minimum Cost to Cut a StickLeetCodeHard Solve Minimum Cost to Cut a Stick on LeetCode (opens in a new tab)
3Shortest Path Visiting All NodesLeetCodeHard Solve Shortest Path Visiting All Nodes on LeetCode (opens in a new tab)
4Burst BalloonsLeetCodeHard Solve Burst Balloons on LeetCode (opens in a new tab)
5ZumaCodeforcesHard 1900Solve Zuma on Codeforces (opens in a new tab)
6FishCodeforcesHard 1900Solve Fish on Codeforces (opens in a new tab)
7Classy NumbersCodeforcesHard 1900Solve Classy Numbers on Codeforces (opens in a new tab)
8Number of Digit OneLeetCodeHard Solve Number of Digit One on LeetCode (opens in a new tab)
9Find the Shortest SuperstringLeetCodeHard Solve Find the Shortest Superstring on LeetCode (opens in a new tab)
10Clear the StringCodeforcesHard 2000Solve Clear the String on Codeforces (opens in a new tab)
11Square SubsetsCodeforcesHard 2000Solve Square Subsets on Codeforces (opens in a new tab)
12Array ShrinkingCodeforcesHard 2100Solve Array Shrinking on Codeforces (opens in a new tab)
13Compatible NumbersCodeforcesHard 2200Solve Compatible Numbers on Codeforces (opens in a new tab)
14Magic NumbersCodeforcesHard 2200Solve Magic Numbers on Codeforces (opens in a new tab)
15Segment SumCodeforcesHard 2300Solve Segment Sum on Codeforces (opens in a new tab)

Sign in to track your progress

Your checkboxes, streak and activity heatmap are saved to your account and sync across devices. It is free.
Sign in with email

New here? Create an account