Removing Digits

You are given an integer n.

On each step, you may subtract one of the digits from the number.

How many steps are required to make the number equal to 0?

Example 1:

Input : 27

Output : 5

Explanation : 27 → 20 → 18 → 10 → 9 → 0, which takes exactly 5 steps

Example 2:

Input : 1

Output : 1

Explanation : 1 → 0 , takes 1 step

Now Your Turn!

Pick the correct output for the given input

Input : 17

Still unsure what the problem is asking ?

Let’s go through a few more examples, step by step, to make it clearer.

Constraints:

  • 1 <= n <= 106

Hints

Frequently Occurring Doubts

Interview Follow-up Questions

0
class Solution {
public:
int removeDigits(int n) {
}
};
Test Case

Input:

N