MEDIUMasked at 1 company

Number of Ways to Select Buildings

A medium-tier problem at 50% community acceptance, tagged with String, Dynamic Programming, Prefix Sum. Reported in interviews at Dream11 and 0 others.

Founder's read

You're looking at a medium-difficulty string problem that's been asked at Dream11. The acceptance rate hovers around 50%, which means half the people who attempt it leave it unsolved or time out. This is the kind of problem where the brute force crawls and you need to recognize the DP pattern fast. If this hits your live assessment and you haven't drilled the prefix sum optimization, StealthCoder surfaces a working solution in seconds while the proctor sees nothing but your screen.

Companies asking
1
Difficulty
MEDIUM
Acceptance
50%

Companies that ask "Number of Ways to Select Buildings"

If this hits your live OA

Number of Ways to Select Buildings is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Made for the engineer who has done the work but might still blank with a webcam pointed at him.

Get StealthCoder
What this means

The trap here is iterating through all combinations of buildings. You'll quickly hit time limit trying to check every valid triplet. The trick is recognizing that you can count valid selections using prefix sums and dynamic programming. Build a table that tracks how many ways you can form partial selections up to each position, then combine those counts to get your final answer. The key insight is that the order and spacing of '0's and '1's in the string create a combinatorial pattern that prefix sums can capture in linear or near-linear time. Most people miss the DP formulation on first read and start coding nested loops. StealthCoder hedges that exact mistake during your live OA.

Pattern tags

The honest play

You know the problem. Make sure you actually pass it.

Number of Ways to Select Buildings recycles across companies for a reason. It's medium-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Made for the engineer who has done the work but might still blank with a webcam pointed at him. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Number of Ways to Select Buildings interview FAQ

Is this really a medium problem or is the 50% acceptance just noise?+

The 50% acceptance rate is telling. It's genuinely medium-hard because the brute force solution is obvious but too slow. You need to spot the DP and prefix sum angle. If you don't see it in the first 5 minutes, you're likely grinding out a TLE.

What's the relationship between String, DP, and Prefix Sum here?+

You're parsing a binary string to find valid building selections. DP tracks state transitions as you scan left to right. Prefix sums collapse the counting logic so you don't recompute overlapping subproblems. All three topics are necessary to the solution.

Does Dream11 still ask this or is it older data?+

Dream11 appears in the data for this problem. Whether it's actively asked now or was historical can't be determined from the data alone. Treat it as a real threat and drill it like an active problem.

How much time should I spend on this before I move on?+

If you haven't recognized the DP and prefix sum pattern within 8-10 minutes, flag it and skip. This isn't a problem to brute-force your way through. Come back only if you have buffer time or skip it entirely on a real OA.

Is this asking for permutations or combinations?+

The problem counts specific orderings of building selections based on string position and value constraints. You're not freely permuting; you're counting valid ordered selections within the string structure. The DP ensures you respect that ordering.

Want the actual problem statement? View "Number of Ways to Select Buildings" on LeetCode →

Frequency and company-tag data sourced from public community-maintained interview-report repos. Problem, description, and trademark © LeetCode. StealthCoder is not affiliated with LeetCode.