FastPrepLazy Chef: Group One Ingredient
Problems/Lazy Chef: Group One Ingredient

Lazy Chef: Group One Ingredient

Intuit logoIntuit● MediumINTERNOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in an Intuit intern online assessment. The report gives adjacent swaps, all target occurrences, and its sample. We chose uppercase string input and the return type of the function. Our version is about 98% the same as the reported question.

Each character of ingredients represents a block containing one ingredient. In one move, swap two adjacent blocks. Find the minimum moves required to make all occurrences of target consecutive anywhere in the sequence. Other ingredients may appear in any remaining order. target is a one-character string and occurs at least once.

Function

groupIngredient(ingredients: String, target: String) → long

Examples

Example 1

ingredients = "HDHSAHS"target = "H"return = 3

Three adjacent swaps can group the H blocks; arbitrary nonadjacent swaps are not allowed.

Example 2

ingredients = "ABBBBA"target = "A"return = 4

Moving the two A blocks together crosses four intervening B blocks.

Constraints

  • 1 <= ingredients.length <= 100000, and the target occurs.
  • For this exercise, assume uppercase ASCII letters and return a signed 64-bit move count.

More Intuit Online Assessment questions

  • Employee Promotion OpportunitiesOA · Seen Oct 2026
  • Next Pascal Row CoefficientOA · Seen Oct 2026
  • Parse Router LogsOA · Seen Oct 2026
  • Longest Repeated Letter Block with Adjacent SwapsOA · Seen Oct 2026
  • Maximum Square-Free DivisorOA · Seen Oct 2026
  • Two Tribes from Taller-Person CountsOA · Seen Oct 2026
  • Shortest Path from an Encoded GraphOA · Seen Sep 2026
  • Oldest and Youngest EmployeesOA · Seen Sep 2026
  • Pressure-Isolation Shutdown OrderOA · Seen Sep 2026
  • Submask Sum QueriesOA · Seen Sep 2026

Similar questions at other companies

  • Minimum No-Repeat Segments After One Character RemovalSalesforce · OASalesforce 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
  • Robot Assembly Line ConflictsGoogle · OAGoogle interview questions
  • Substring RemovalJP Morgan Chase · OAJP Morgan Chase interview questions
  • Minimum Additions to Make a Valid ABC StringIBM · OAIBM interview questions
  • Maximize Workday EarningsCitadel · OA · PHONE SCREEN · ONSITE INTERVIEWCitadel interview questions
  • Minimum Adjacent TranspositionsEpic · OAEpic interview questions
  • Maximum String OperationsMicrosoft · OAMicrosoft interview questions

Interview reports that mention this question

  • Intuit OA: What It Tests (2026)

Intuit interview experiences

  • Intuit Software Engineering Intern - Full Stack OA Format
All Intuit interview questionsSee Intuit hiring insights
Saved
class Solution {
    public long groupIngredient(String ingredients, String target) {
        // Write your code here
    }
}
Checking account…