← Questions

Microorganisms eating neighbours: the largest survivor

0
OpenAICodingLast asked Oct 2026

Microorganisms stand in a row. Each one has a family (a letter) and a size (a positive integer). A microorganism can eat the neighbour directly to its left or right when that neighbour is from a different family and strictly smaller. The simulation runs in rounds, scanning the row from left to right, and stops when no one can eat anyone.

Simulate it and return the size of the largest microorganism left at the end. Be precise about how one round proceeds and about what happens to sizes when one eats another, and say how fast your simulation runs.

Write and test your solution herePython in your browser, the question's tests level by level, every submission kept for you.Sign in to start coding