cswork / OAOpen practice workspace

IntuitOA #6

Node Disconnection — Min Ops

Estimated HardStatement and editorial — judging is being prepared

Topics (AI-labelled)String DP

Secure a compromised communication network by disconnecting all nodes. There is a series of nodes (each represented by lowercase English letters) in a string. In a single operation, you can disconnect any number of adjacent nodes that are the same letter.

Determine the minimum number of operations required to disconnect all nodes and secure the network.

Example: s = "aabaa" → 2 (remove the run of a at the ends together via the middle, then remove b).

Editorial

Loading solution…