Question: Cepheid Coding Questions Jan 30th | Array Traversal & Angular Framework Concepts | Recent Online Assessment 2026 | Peak Output Coding & Angular MCQs
1
Entering edit mode

 Section 1: Coding Question

Question: Peak Output

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:

  • N: Represents the number of working days.
  • workload: Represents workload[i] denoting the number of hours an employee worked on an i^{th} 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 the i^{th} day.

 


Section 2: Angular Framework MCQs

Question 1: Angular Elements

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:

  1. Angular Elements allow you to package Angular components as web components.
  2. Angular Elements are similar to Custom Elements but have some additional capabilities.
  3. To create an Angular Element, you need to use the "@angular/elements" package and register the component as a custom element.
  4. Angular Elements work in all modern browsers, including Internet Explorer.

Options:

  • 1, 2, and 3
  • 2, 3, and 4
  • 1, 3, and 4
  • 1, 2, and 4

Question 2: Angular Services

What decorator is used to mark a class as an Angular service?

Options:

  • @Service
  • @Injectable
  • @Component
  • @Provider

Question 3: Angular Router Lifecycle

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:

  1. It activates Angular components to display the page.
  2. It runs the guards that are defined in the router state.
  3. It resolves the required data for the router state.
  4. It figures out which router state corresponds to the URL.
  5. It manages navigation and repeats the steps when a new page is requested.

Options:

  • 2, 4, 3, 1, and 5
  • 4, 2, 3, 1, and 5
  • 4, 3, 1, 2, and 5
  • 2, 1, 4, 3, and 5

Question 4: Attribute Binding

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:

  1. Attribute binding is used to set the value of an attribute of an HTML element.
  2. Attribute binding is two-way only, which means changes to the attribute value in the HTML element will also update the component's property.
  3. The square brackets syntax is used for attribute binding in Angular.
  4. Attribute binding can be used to apply conditional logic based on the value of an attribute.

Options:

  • 1, 2, and 3
  • 2, 3, and 4
  • 1, 2, and 4
  • 1, 3, and 4

Question 5: Debugging Angular Logic

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:

  1. The button element is not included in the component template
  2. The backgroundColor variable is not defined in the component
  3. The changeColor() method is not called on button click
  4. The component template does not have the property binding to update the background color

Option Sets:

  • 1 and 2
  • 3 and 4
  • 1 and 3
  • 2 and 4
ADD COMMENTlink 16 days ago admin 1.9k
0
Entering edit mode

Problem 1 Solution

Peak Output Solution

Topics Involved / Prerequisites

  • Array Traversal
  • State Maintenance (Counting contiguous elements)

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.

  • Ifworkload[i] > 6: The employee worked more than 6 hours. We increment our current_peak by 1. We then immediately compare current_peak against max_peak and update max_peak if the current streak is longer.
  • Ifworkload[i] <= 6: The streak is broken. We reset current_peak to 0 and continue to the next 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

  • Time Complexity: O(N) - We iterate through the workload array of size N exactly once, performing constant time O(1) checks at each step.
  • Space Complexity: O(1) auxiliary space - We only use a few integer variables for counting, requiring no additional scaling memory regardless of how large N gets.
ADD COMMENTlink 16 days ago admin 1.9k
0
Entering edit mode

Section 2: Angular Framework MCQs

Answers:

  • Question 1: 1, 2, and 3

  • Question 2: @Injectable

  • Question 3: 4, 2, 3, 1, and 5

  • Question 4: 1, 3, and 4

  • Question 5: 2 and 4

ADD COMMENTlink 16 days ago admin 1.9k

Login before adding your answer.

Similar Posts
Loading Similar Posts