Question: Maximum Streak A project manager wants to look at employee attendance data. Given that m employees are working on the project, and the manager

Maximum Streak A project manager wants to look at employee attendance data.

   

Given that m employees are working on the project, and the manager

has the record of the employees present on n days of the

project, help him find the maximum number of consecutive days on which

all employees were present and working on the project. As an example,

Maximum Streak A project manager wants to look at employee attendance data. Given that m employees are working on the project, and the manager has the record of the employees present on n days of the project, help him find the maximum number of consecutive days on which all employees were present and working on the project. As an example, there are m = 3 employees and n = 5 workdays to analyze. The attendance data strings, data = [YYY, YYY, YNN, YYN, YYN]. There are only two days, at the beginning of the period, where all workers are present. Using zero indexing for employees, employees 1 and 2 are absent on the third day, and employee 2 is also out on the fourth and fifth days. The maximum streak occurs at the beginning and is 2 days long. Function Description Complete the maxStreak function in the editor below. The function must return an integer denoting the maximum number of consecutive days where all the employees of the project are present. maxStreak has the following parameters: m: an integer denoting the number of employees working on the project. data: an array of n strings, where the value of each element data[i] is a string where data[i][j] denotes if the jth employee is present on the ith day. Constraints 1 m 10 1 n 100000 Each data[i][j] = {'Y', 'N'} Input Format For Custom Testing The first line contains an integer, m, the number of employees in the project. Next line contains an integer, n, the number of elements in data. Sample Case 0 Sample Input 0 2 2 YN NN Sample Output 0 0 Explanation 0 There are no days in data which indicate that all the employees are present. Sample Case 1 Sample Input 1 3 1 NYY Sample Output 1 0 Explanation 1 There are no days in data which indicate that all the employees are present. Sample Case 2 Sample Input 2 4 5 YNYY YYYY YYYY YYNY NYYN Sample Output 2 2 import java.io.*; 2 import java.math. *; 3 import java.security.*; 4 import java.text.*; 5 import java.util.*: W N 56789 8 10 class Result { 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 import java.util.concurrent. *; import java.util.regex.*; 29 30 31 } /* * Complete the 'maxStreak' function below. * * The function is expected to return an INTEGER. * The function accepts following parameters: * 1. INTEGER m * */ 2. STRING_ARRAY data public static int maxStreak(int m, List data) { // Write your code here } 26 public class Solution { 27 28 public static void main(String[] args) throws IOException { Buffered Reader buffered Reader = new Buffered Reader (new InputStreamReader (System.in)); Buffered Writer buffered Writer = new BufferedWriter (new FileWriter (System.getenv("OUTPUT_PATH"))); int m= Integer.parseInt(buffered Reader.readLine().trim()); 32 33 34 35 int dataCount = Integer.parseInt (buffered Reader.readLine().trim()); List data = new ArrayList (); 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 } 51 Listhott mig? Gala TICWAITaytiotv' for (int i = 0; i < dataCount; i++) { String dataltem = bufferedReader.readLine(); data.add(dataltem); } int result Result.maxStreak (m, data); buffered Writer.write(String.value0f (result)); buffered Writer.newLine(); bufferedReader.close(); buffered Writer.close(); Line: 23 Col: 1

Step by Step Solution

3.49 Rating (166 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!