Question: Amazon | 23rd Aug 2025 | OA | | Minimize Finish Time | Binary Ad Visibility | Greedy Array Grouping & Bit Manipulation | Aug 23rd Campus Assessment
0
Entering edit mode

Question 1: Minimize Finish Time

Problem Statement: You are given two arrays: arr1 of size n and arr2 of size 4 * n. Your task is to divide arr2 into n groups, with 4 elements in each group, and assign each group to one element in arr1.

Each element in arr1 represents a base time. When you assign a group to a base time, each of the 4 elements in that group is added to the base time to produce 4 finish times. The finish time for that group is the maximum of these 4 times.

Your goal is to find an assignment that minimizes the finish time across all groups.

Function Inputs:

  • int arr1[n]: an array of integers

  • int arr2[4*n]: an array of integers

Returns:

  • The function should return an integer, the minimum possible finish time for all groups.

Example:

  • n = 2

  • arr1 = [8, 10]

  • arr2 = [2, 2, 3, 1, 8, 7, 4, 5]

(Optimal solution mapping is required to find the minimal max finish time).


Question 2: Change Ads (Binary State)

Problem Statement: An e-commerce platform displays advertisements based on a binary state representation. In this system, 1 indicates a displayed ad and 0 indicates a hidden ad. The platform requires ads to alternate their visibility on each page load.

Given an integer in base 10 representing the current display state of all ads:

  1. Convert the integer to its binary representation.

  2. Starting from the highest order 1 bit, invert that bit and all lower order bits (change 0s to 1s and 1s to 0s).

  3. Return the base 10 representation of the resulting binary number.

Example: base10 = 30

30 (base 10) = 00011110 (base 2)

Strip the insignificant zeros, then flip all of the bits in 11110 (base 2) to get 00001 (base 2) = 1 (base 10). The example shows the value as an 8-bit binary to demonstrate that preceding zeros are discarded.

Function Description: Complete the function changeAds in the editor.

ADD COMMENTlink 7 hours ago Rohit • 30

Login before adding your answer.

Similar Posts
Loading Similar Posts