Your Dashboard
Interview Coaching
Learn
System Design
ML System Design
Code
Behavioral
Salary Negotiation
Interview Guides
Search
⌘K
Get Premium
Leetcode 2222. Number of Ways to Select Buildings
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)).
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
All Regions
Comments
Hello Interview Premium
Your account is free and you can post anonymously if you choose.