function getSubstringCount(s) { // Write your code here let [current, prev, result] = [1, 0, 0] for(let i=1; i<s.length; i++){ let left = s[i-1] let right = s[i] if(left == right){ current++ } else { prev = current current = 1 } if(prev >= current){ result++ } } return result }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter