Geeksforgeeks

Error

×

Leaderboard

Showing:

Handle | Score |
---|---|

@Ibrahim Nash | 6560 |

@blackshadows | 6400 |

@mb1973 | 5777 |

@Quandray | 5275 |

@akhayrutdinov | 5111 |

@saiujwal13083 | 5074 |

@kirtidee18 | 4419 |

@sanjay05 | 3762 |

@mantu_singh | 3666 |

@gfgaccount | 3605 |

@marius_valentin_dragoi | 3525 |

Complete Leaderboard | |

Handle | Score |

@anish5256 | 991 |

@vimleshpratapsingh321 | 980 |

@skj7 | 957 |

@kanewilliamson123 | 894 |

@pradeeppatidar1999 | 868 |

@akhileshkumar562002 | 862 |

@wallflowe101 | 826 |

@pd420786 | 813 |

@infilooop | 800 |

@nikhilkushwah280 | 796 |

@bunnybug320 | 796 |

Complete Leaderboard |

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|<=10^{6}

Login to report an issue on this page.

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

YesLoading...

Count digits in given number N which divide N

...