Company: Swiggy
Difficulty: medium
Extraordinary Substrings Each character of the lowercase English alphabet has been mapped to digits as shown in the figure: 1 (ab) 2 (cde) 3 (fgh) 4 (ijk) 5 (lmn) 6 (opq) 7 (rst) 8 (uvw) 9 (xyz) An extraordinary substring is one whose sum of the mapped values of each letter is divisible by its length. Given string input_str , count its total number of non-empty extraordinary substrings. Function Description Complete the function countSubstrings in the editor. countSubstrings has the following parameter(s): string input_str : a string of length n Returns int : the number of non-empty extraordinary substrings Constraints 1 ≤ n ≤ 2000 All characters of input_str are lowercase English letters. Sample Case 0 Input: bdh Output: 4 The extraordinary substrings are \'b\', \'d\', \'h\' and \'bdh\'. Example Calculation Table String Mapped Sum Length Is divisible b 1 1 1 Yes d 2 2 1 Yes h 3 3 1 Yes bdh 1,2,3 6 3 Yes .mapping-table { border-collapse: collapse; margin: 1em 0; } .mapping-table td { b