← All problemsSign in

ISLANDS AND PIRATES

ISLANDS AND PIRATES There are n Islands in a line in an area. There are two kinds of Pirates A and B that reside there. A Islands can be either empty or occupied by one of the Pirates. An empty Islands is said to be controlled by a tribe of Islands A if it is surrounded by Islands of Pirates A from the left and from the right. Same goes for the tribe B. Find out the number of Islands that are ei

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start