The TransCompilator

Solved LeetCode program · 497 of 1,000

#0696 · Count Binary Substrings

Easy String chunk-10.md

Original English source

The source is "00110011". The last is the last position of source. The previous is 0. The current is 1. The total is 0.
For every spot from 1 to last.
The rightletter is character spot of source. The leftletter is character (spot minus 1) of source. If rightletter is leftletter, add 1 to current. If rightletter is not leftletter, The joined is the smaller of previous and current, add joined to total, set previous to current, set current to 1.

The extra is the smaller of previous and current. Add extra to total. Show total.

Open in Playground Browse all 1,000 problems

Expected stdout

6