FastPrepGet Minimum Operations
Problems/Get Minimum Operations

Get Minimum Operations

IBM logoIBM● MediumFULLTIMEOA

Updated Sep 2026

QuestionFunctionExamplesConstraints

Problem statement

Implement a function that returns the minimum number of operations needed to ensure the string s (of length n) contains no segments of exactly m consecutive '0's.

In one operation, you can do the following:

  • Select a contiguous segment of length k and make every bit in this segment '1'.

The function getMinOperations will take three inputs:

  • string s: a string representing s.
  • int m: an integer representing m.
  • int k: an integer representing k.

The function should return an integer representing the minimum number of operations needed.

Function

getMinOperations(s: String, m: int, k: int) → int

Examples

Example 1

s = "000000"m = 3k = 2return = 1

We can perform an operation on the interval [3, 4] (1-based indexing) to get "001100", ensuring no segment of consecutive 0s has a length ≥ 3. Thus, the answer is 1.

Constraints

  • 1 ≤ n ≤ 2 * 10^5
  • 1 ≤ m, k ≤ n

More IBM interview questions

  • Missing IntervalsOA · Seen Nov 2026
  • Count Peaks and ValleysOA · Seen Nov 2026
  • Last Object Exit TimeOA · Seen Nov 2026
  • Count Strictly Increasing Contiguous WindowsOA · Seen Nov 2026
  • Total Each Letter's Count in an Encoded StringOA · Seen Nov 2026
  • Count Servers With No Requests in a Time WindowOA · Seen Nov 2026
  • Alternate Odd and Even Numbers with Two GoroutinesPHONE SCREEN · Seen Nov 2026
  • Longest Substring Without Repeating CharactersPHONE SCREEN · Seen Nov 2026
  • Maximum Easy Tasks After RearrangingOA · Seen Nov 2026
  • Longest Palindromic SubstringPHONE SCREEN · Seen Oct 2026

Similar questions at other companies

  • Maximize Consecutive Dance Moves 🩰TikTok · OATikTok interview questions
  • Longest Repeated Letter Block with Adjacent SwapsIntuit · OAIntuit interview questions
  • Earn the Most 🐝Capital One · OACapital One interview questions
  • Maximum String OperationsMicrosoft · OAMicrosoft interview questions
  • Perfect SubstringAXQ Capital · OA
  • Minimum No-Repeat Segments After One Character RemovalSalesforce · OASalesforce interview questions
  • Reschedule Meetings for Maximum Free TimeFivetran · OAFivetran interview questions
  • Longest Non-Decreasing Substring After Pair SwapsVisa · OAVisa interview questions
  • Minimum Deletion Cost for Distinct Adjacent CharactersHSBC · OAHSBC interview questions
  • Minimum Binary Swaps to a PalindromeAT&T · OAAT&T interview questions

IBM interview experiences

  • IBM Full-Time SWE OA Questions: 1 Experience
  • IBM Software Intern Résumé Rounds: 2 Experiences (Part 3 of 3)
  • IBM Intern Blitz Interviews: 23 Experiences (Part 2 of 3)
  • IBM Software Intern Interviews: 44 Experiences (Part 1 of 3)
  • IBM Software Intern Interview Questions: 15 Experiences
All IBM interview questionsSee IBM hiring insights
Saved
class Solution {
    public int getMinOperations(String s, int m, int k) {
      // write your code here
    }

}
Checking account…