Leaderboard
Showing:
Count digits in given number N which divide N
Basic Accuracy: 60.0% Submissions: 35 Points: 1

Given a number S(in the form of a string). Count all the digits in S which divide S. Divisibility by 0 is not allowed. If any digit in S which is repeated divides S, then all repetitions of that digit should be counted.

Example 1:

Input:
S = "35"
Output:
1
Explanation:
Only 5 digits 35,thus the answer is 1.

Example 2:

Input:
S = "1122324"
Output:
7
Explanation:
All the digits divide 1122324, therefore,
the answer is 7.


Your Task:
You don't need to read input or print anything.Your task is to complete the function divisibleByDigits()  which takes the number S(in the form of a string) as input parameter and returns the number of digits of S that divide S.


Expected Time Complexity: O(N)
Expected Auxillary S
pace: O(constant)


Constraints:
1<=|S|<=106

to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.

Count digits in given number N which divide N

Output Window