Fill One Exact-Length Binary Window
Problem statement
Given a binary string log and an integer k, choose exactly one contiguous substring of length k. Change every 0 inside it to 1. Ones inside the window and all characters outside it stay unchanged.
The problem statement continues
ProExamples
Example 1
log = "11001"k = 2return = 5Choose the two zeros at indices 2 and 3 in 11001. Filling that length-2 window gives 11111, so the answer is 5.
FastPrep Pro
Reported in 2 Amazon interviews this weekUnlock this recently reported problem
FastPrep Pro gives you full access to interview problems reported within the last week.
- Full problem statement and constraints
- 1 more worked example, explained
- Guided hints and editorial
- Run your code on real test cases
$8.25/month
$99 billed yearly — or $19 month-to-month. Cancel anytime.
Free plan — 2 of 2 free unlocks used this week