Problem Statement
Class name: TargetGrid Method name: minShots Arguments: String[] Returns: int In this video game, a set of targets pop up on a grid. You have arms that move along two sides of the grid. One shoots horizontally, taking out all targets in a row. The other shoots vertically, hitting all targets in a column. However, ammunition is limited, so it is necessary to eliminate all targets in as efficient a manner as possible. Write a class TargetGrid containing a class minShots. minShots returns the minimum number of shots needed to take out all targets on a grid of size up to 25x25. The method signature is: public int minShots(String[] targets) (be sure you declare the method public) targets will contain a set of 1-25 Strings; these Strings will all be the same length (1-25). The Strings will consist solely of the characters 'N' (no target) and 'T' (target). (These conditions will be checked by TopCoder.) The method should return an int that is the smallest number of rows and columns combined that can be selected which will encompass all targets. EXAMPLES: NTNTNTT TNNNNNN TTNTTNT TNNTNNT NTNTNTN NTNTNTT NNNTTTT This returns 6 - one shot for each column other than the third. NNTNNNTN NTTTNTNT NNTNNNNN NNNNNNTN TNTNTTTT NNNNNNTN NNTNNNTN NNNNNNNN This returns 4 - 2nd row, 5th row, 3rd column, 7th column.
Definition
- Class:
- TargetGrid
- Method:
- minShots
- Parameters:
- String[]
- Returns:
- int
- Method signature:
- int minShots(String[] param0)
- (be sure your method is public)
Constraints
Examples
No public sample cases were explicitly marked for this problem in the original data.