Loading Now

evenSubStrings

You are given a string s, which only contains digits 1,2,..,9.

A substring s[l,r] of s is called even if the number represented by it is even.

Find the number of even substrings of s. Note, that even if some substrings are equal as strings, but have different l and r, they are counted as different substrings.

Example

  • For s = "1234" the output should be evenSubStrings(s) = 6
    The pairs corresponding to even substrings are 4, 34, 234, 1234, 2, 12

Input/Output

  • [execution time limit] 0.5 seconds 
  • [Input] string s
    0 <= s.length <= 100
  • [Output] int
    The number of even substrings of s.

Post Comment

Contact