Problem Statement
A teacher wants to take his students to see a movie at the theater. The only problem is that the students talk a lot, so the teacher doesn't want any two students in the same row to sit in adjacent seats.
You are given a String[] seats which contains information about which seats are available for purchase. Character j of element i of seats is 'Y' if the j-th seat in row i is available, or 'N' otherwise. Return the maximum number of students who can watch the movie.
You are given a String[] seats which contains information about which seats are available for purchase. Character j of element i of seats is 'Y' if the j-th seat in row i is available, or 'N' otherwise. Return the maximum number of students who can watch the movie.
Definition
- Class:
- VeryInterestingMovie
- Method:
- maximumPupils
- Parameters:
- String[]
- Returns:
- int
- Method signature:
- int maximumPupils(String[] seats)
- (be sure your method is public)
Constraints
- seats will contain between 1 and 50 elements, inclusive.
- Each element of seats will contain between 1 and 50 characters, inclusive.
- All elements of seats will be of equal length.
- Each element of seats will contain only 'Y' or 'N' characters.
Examples
{"YY","YY","YY"}Returns: 3
Only one student can sit in each row.{"NNNNN","NNNNN","NNNNN","NNNNN","NNNNN"}Returns: 0
No places are available.{"YYYYYYN","YYYYNYY","NYYYNYY","NYYYYYN","YYYYYYN","NYYNYNY","YYYYYYY"}Returns: 22