Maximum Streak A project manager wants to look at employee attendance data. Given that m employees...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
✩ 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<String> 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<String> 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 ✩ 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<String> 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<String> 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
Expert Answer:
Related Book For
Fundamentals of Corporate Finance
ISBN: 978-0077861629
8th edition
Authors: Richard Brealey, Stewart Myers, Alan Marcus
Posted Date:
Students also viewed these programming questions
-
Resolve Problem 4.19 with α = .1 and β = .8. Using MSE, determine which smoothing constants provide a better forecast. In Problem 4.19, Income at the law firm Smith and...
-
Resolve Problem 14- 12 (Goodeating Dog Chow) for five periods. In Problem 14- 12, Goodeating Dog Chow Company produces a variety of brands of dog chow. One of their best values is the 50-pound bag of...
-
Resolve Problem 5-31 with = 0.3. Using MAD, which smoothing constant provides a better forecast? In Problem 5-31 Consulting income at Kate Walsh Associates for the period FebruaryJuly has been as...
-
Marquis Company uses a weighted-average perpetual inventorysystem. August 2, 22 units were purchased at $3 per unit. August 18, 27 units were purchased at $5 per unit. August 29, 24 units were sold....
-
Condensed income statements for Saunder Company for two years are presented here. After the end of 2012, it was discovered that an error had been made in 2011. Ending inventory in 2011 should have...
-
After researching the different forms of business organization. Natalie Koebel decides to operate Cookie Creations as a proprietorship. She then starts the process of getting the business running. In...
-
In a 1975 contract, Eureka was given the exclusive right to sell spring water and other products under the Ozarka trade name in 60 Oklahoma counties in exchange for \($9,000\) paid to Arrowhead,...
-
(Corrected Trial Balance) The trial balance of Antoine Watteau Co. shown below does not balance. Each of the listed accounts has a normal balance per the general ledger. An examination of the ledger...
-
For each of the following matrices A Maxn (R), test A for diagonal- izability, and if A is diagonalizable, find an invertible matrix Q and a diagonal matrix D such that Q-1AQ = D. (a) (63) 2 1 3 (b)...
-
Lee Nicholas has been the owner and has operated World.com Advertising since its beginning 10 years ago. The company has prospered. Recently, Nicholas mentioned that he would sell the business for...
-
In what ways, if any, is your company (H&R block) exercising corporate social responsibility? What are the elements of your companys CSR strategy? Are there any changes to this strategy that you...
-
AI, rewrite, I have been with CBRE for over five years providing administrative support to various departments, legal, corporate responsibility, CBRE Cares and currently the People Team. I am...
-
Assignment- Determining Out-of-Pocket Costs is a set of quantitative questions comprising two parts. In Part 1, you examine an insurance identification card and determine key information. In Part 2,...
-
Futures and forwards are (choose all that apply): Group of answer choices Useful for hedging Very similar to options in that the buyer of the contract has the option not to exercise Used to take...
-
Question 1 An interest-bearing note payable on the balance sheet of CMA Co. will require the following payments: 1 point Stated face amount at issuance along with periodic interest payments...
-
2-The service provided is allowable perpatient's benefit coverage once every 3years. Patient has previously met theirallowance for the time period.Remittance Advice: States theservice performed...
-
Sand is an important raw material used in the construction of buildings, roads, and the manufacture of glass. Despite its importance in the economy. There are no futures contracts for sand. Appraise...
-
What is an insurable interest? Why is it important?
-
Suppose that the market value (in thousands of dollars) of Fincorp's fixed assets in 2014 is $6,000 and that the value of its long-term debt is only $2,200. In addition, the consensus among investors...
-
If the interest rate this year is 8% and the interest rate next year will be 10%, what is the future value of $1 after 2 years? What is the present value of a payment of $1 to be received in 2 years?
-
Construct a balance sheet for Fincorp for 2013 and 2014. What is shareholders' equity?
-
Let \(X_{1}, \ldots, X_{n}\) be a set of independent and identically distributed random variables from a distribution \(F\) with variance \(\mu_{2}\) where \(E\left(\left|X_{1}ight|^{4}ight) a. Prove...
-
Consider a sequence of independent random variables \(\left\{X_{n}ight\}_{n=1}^{\infty}\) where \(X_{n}\) has probability distribution function \[f_{n}(x)= \begin{cases}2^{-(n+1)} &...
-
Let \(X_{1}, \ldots, X_{n}\) be a set of independent and identically distributed random variables from a shifted exponential density of the form \[f(x)= \begin{cases}\exp [-(x-\theta)] & \text { for...
Study smarter with the SolutionInn App