DiamondHunt
SRM 346 · 2007-04-24 · by soul-net
Problem Statement
You are a diamond hunter looking for diamonds in a peculiar mine. This mine is a
For example, if you have a mine like "><<><>>><", you can start by removing the first appearance of "<>" to get "><<>>><", then remove the only remaining diamond to get "><>><". Note that this produces a new diamond which you can remove to get ">><". Since there are no diamonds left, your expedition is done.
Given a
Constraints
- mine will contain between 1 and 50 characters, inclusive.
- Each character of mine will be either '<' or '>'.
"><<><>>><" Returns: 3
The example from the problem statement.
">>>><<" Returns: 0
No diamonds here.
"<<<<<<<<<>>>>>>>>>" Returns: 9
"><<><><<>>>><<>><<><<>><<<>>>>>><<<" Returns: 14
"<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>" Returns: 25
Submissions are judged against all 74 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class DiamondHunt with a public method int countDiamonds(string mine) · 74 test cases · 2 s / 256 MB per case