Tag Archives: divisibility

Number of even substrings in a string of digits

Given a string of digits 0 – 9. The task is to count number of substrings which when convert into integer form an even number. Examples: Input : str = “1234”. Output : 6 “2”, “4”, “12”, “34”, “234”, “1234” are 6 substring which are even. Input : str = “154”. Output : 3 Input… Read More »