Company: visa_6oct
Difficulty: medium
Alien Code Substrings Divisible by 3 Problem Description Imagine you're part of a team analyzing fictional alien technology logs. You have a string alienCode , which represents activity codes from their devices. Your task is to examine this string and count how many substrings of this code represent numbers evenly divisible by 3. It's important to note that none of these substrings should start with zero unless the substring is the character "0" itself. Note: You are not expected to provide the most optimal solution, but an O(alienCode.length) solution is expected, using the fact that a number is divisible by 3 if and only if the sum of its digits is divisible by 3. A string of digits representing alien device activity codes. Input: string alienCode Output: integer (Return the number of substrings that form an integer divisible by 3.) Examples Example 1: Input: alienCode = "456" Output: 3 Explanation: Consider all substrings of the given string: alienCode[0..0] = 4 isn't divisible by 3