Given a string of integers, find the count of sub-strings of given string which are divisible by 6. This problem can be solved using Dynamic Programming in O(N) time complexity where N is the length of the string.
For example 1.
Input: "68412" Output: 6
Explanation: Since 6, 84, 12, 684, 8412, 68412 are the only substrings which are divisible by 6.
Example 2.
Input: "350648" Output: 6
Explanation : 0, 6, 48, 648, 5064, 35064 are the only substrings which are...
Published on November 09, 2020 23:31