Question: Write a Java method which accepts a strings and an integer k as parameters. The string s consists of digits ('0' to '9') and
Write a Java method which accepts a strings and an integer k as parameters. The string s consists of digits ('0' to '9') and wildcards (?). The length of s is at most 8 and the number of wildcards is at most 3. Replace each wildcard with any digit, however, if the wildcard is in the first position of the string, you could not replace it with '0'. The method returns the total number of numbers formed which are divisible by k. Sample Input s="?141", k=3 s="???", k=11 s = "9?2253??", k=7 Sample Output 3 81 143
Step by Step Solution
3.40 Rating (166 Votes )
There are 3 Steps involved in it
Heres a Java method that solves this problem java public class DivisibleByK public static int countN... View full answer
Get step-by-step solutions from verified subject matter experts
