Problem Statement:
The workload of an employee is the number of hours the employee works in a day. Given the workload of an employee over N working days (workload), compute the Peak output for the employee.
Peak Output is the maximum number of consecutive working days when the employee has worked for more than 6 hours.
Function Description:
Complete the solve() function. This function takes the following 2 arguments and returns the peak output.
Parameters:
Input Format:
Alice is creating an Angular application and wants to convert some of the components to web components so that they can be used in non-Angular applications. Which of the following statements are true about Angular Elements?
Statements:
Options:
What decorator is used to mark a class as an Angular service?
Options:
Which of the following is the correct order of steps that are followed by an Angular router after reading the browser URL and applying a URL redirect?
Steps:
Options:
Anita is developing an Angular application and wants to apply conditional logic based on the value of an attribute of an HTML element. Which of the following statements is/are true about attribute binding in Angular?
Statements:
Options:
Code: HTML
<button (click)="changeColor()">Change Color</button>
Code: TypeScript (Angular)
TypeScript
changeColor() {
this.backgroundColor = 'red';
}
Problem Statement:
However, the above code does not seem to work as expected. She wants your help in identifying the issue. Which of the following options could be the reason why the code is not working as expected?
Options:
Option Sets:
Topics Involved / Prerequisites
Overview
The problem requires us to find the longest contiguous subarray (streak) where every element strictly exceeds a specific threshold (6 hours). By keeping a running counter of consecutive days that meet this condition, we can easily track the maximum streak in a single pass through the data.
Approach
1. State Variables
We need two variables: current_peak to track the ongoing streak of days with >6 hours of work, and max_peak to store the highest streak we have encountered so far. Both are initialized to 0.
2. Array Traversal
We iterate through the workload array day by day.
C++ Code -:
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int solve(int N, const vector<int>& workload) {
int max_peak = 0;
int current_peak = 0;
for (int i = 0; i < N; ++i) {
if (workload[i] > 6) {
current_peak++;
max_peak = max(max_peak, current_peak);
} else {
current_peak = 0;
}
}
return max_peak;
}
Time and Space Complexity