Available question text
Count the number of index triples i<j<k in a binary string that form an alternating pattern "010" or "101" (so no two consecutive selected buildings have the same type). This reduces to summing, for each middle index, the product of opposite-bit counts on its left and right (can be done with prefix/suffix counts in O(n)).
Related questions
Continue with questions that share topics or the same question type.
Sources · 1 reference
These records explain where the question appears. A company tag or candidate report does not guarantee a future interview question.
Hello Interview · 1 record
No company association
Leetcode 2222. Number of Ways to Select Buildings
Reported date not specified · 0 source reports
Source snapshot: Nov 12, 2026
View source