FastPrepLargest Microorganism After Consumption

Largest Microorganism After Consumption

OpenAI logoOpenAI● MediumFULLTIMEOA

Problem statement

Microorganisms are arranged from left to right. Microorganism i has family families[i] and positive size sizes[i].

The simulation proceeds in rounds. At the start of each round, every surviving microorganism is eligible to participate once. Scan the current line from left to right:

  1. If the current microorganism and its immediate left neighbor have not participated this round, and the left neighbor is strictly smaller, the current microorganism eats the left neighbor.
  2. Otherwise, if the current microorganism and its immediate right neighbor have not participated this round, and the right neighbor is strictly smaller, the current microorganism eats the right neighbor.
  3. Otherwise, it does nothing.

When one microorganism eats another, the eater gains the target's size, the target disappears, and the eater cannot participate again in that round. Earlier removals immediately change which microorganisms are adjacent.

The problem statement continues
Pro

Examples

Example 1

families = ["A","B","C"]sizes = [3,1,2]return = "A 6"

In the first round, A eats B and grows to 4. In the next round, A eats C and grows to 6.

Original screenshot from the interview report
Pro
FastPrep Pro
Reported in 1 OpenAI interview this week

Unlock this recently reported problem

FastPrep Pro gives you full access to interview problems reported within the last week.

  • Full problem statement and constraints
  • 2 more worked examples, 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
See OpenAI hiring insights
CodePython 3
Run and Submit unlock with Pro
FastPrep Pro
Reported in 1 OpenAI interview this week

Unlock this recently reported problem

FastPrep Pro gives you full access to interview problems reported within the last week.

  • Full problem statement and constraints
  • 2 more worked examples, 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