Employee rating
Practice
3.1 (21 votes)
Real world
Algorithms
Linear search
Problem
64% Success 8420 Attempts 20 Points 2s Time Limit 256MB Memory 1024 KB Max Code

You are an IT company's manager. Based on their performance over the last N working days, you must rate your employee. You are given an array of N integers called workload, where workload[i] represents the number of hours an employee worked on an ith day. The employee must be evaluated using the following criteria:

  • Rating = the maximum number of consecutive working days when the employee has worked more than 6 hours.

You are given an integer N where N represents the number of working days. You are given an integer array workload where workload[i] represents the number of hours an employee worked on an ith day.

Task

Determine the employee rating.

Example

Assumptions

  • N = 12
  • workload = [2, 3, 7, 8, 7, 6, 3, 8, 12, 11, 12, 10]

Approach

Workload with consecutive hours > 6 = [2, 3, 7, 8, 7, 6, 3, 8, 12, 11, 12, 10] => Longest Interval = [8,12,11,12,10]

Therefore return 5.

Function description

Complete the Solve() function provided in the editor below that takes the following arguments and returns the employee rating:

  • N: Represents the number of working days
  • workload: where workload[i] represents the number of hours an employee worked on an ith day

Input format

  • The first line contains an integer N denoting the number of working days.
  • The second line contains a space-separated integer array workload where workload[i] represents the number of hours an employee worked on an ith day.

Output format

Print the employee rating.

Constraints

1≤N≤105

1≤workload[i]≤12

Sample Input
7
3 7 8 12 4 9 8
Sample Output
3
Explanation

Assumption

  • N = 7
  • workload[] = {3, 7, 8, 12, 4, 9, 8}

Approach

  • At day 2, 3, 4, 6 and 7, employees work for more than 6 hours.
  • So maximum number of consecutive days would be 3 [2, 3, 4] when employees work for more than 6 hours.

Therefore we will return 3 as an answer.

Code Editor

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Submissions
Please login to view your submissions
Similar Problems
Points:20
175 votes
Tags:
Ad-HocEasy
Points:20
176 votes
Tags:
Ad-HocApprovedBasic ProgrammingEasyOpen
Points:20
5 votes
Tags:
MathAlgorithmsLinear Search
Editorial

Login to unlock the editorial