Pattern : 8 QS( 2 DSA + 6 MCQS)

You are given a binary string s consisting only of '0' and '1', and an integer k.
In one operation, you may choose any index i (0 ≤ i < n) and flip the bit at that position:
'0' becomes '1''1' becomes '0'Perform at most k operations.
Your task is to determine the maximum possible number of '1's in the final string.
int getMaximumOnes(string s, int k);
s — a binary string.k — the maximum number of operations allowed.'1's after performing at most k operations.The first line contains the binary string s.
The second line contains an integer k.
Print a single integer — the maximum possible number of '1's after at most k operations.
1 ≤ |s| ≤ 2 × 10^50 ≤ k ≤ |s|s contains only '0' and '1'.00011
2
4
Flip the bits at indices 0 and 1.
00011
↓
11011
The resulting string contains 4 ones, which is the maximum possible.
10110
1
4
Flip the bit at index 1.
10110
↓
11110
The resulting string contains 4 ones.
Expedia • Pending
Teradata • Pending
Teradata • Pending
Teradata • Pending