Question: Amazon OnCampus OA 2026 | Coding Assessment | Complete Solutions & Tips | Array Prefix Operations & String Permutations | Aug 29th Campus Assessment
0
Entering edit mode

Question 1: Maximize Zeroes

Problem Statement:

In an Amazon analytics team, the Analysts collectively have a preference for the number zero and a disapproval towards negative numbers. Their objective is to determine the maximum number of zeroes achievable after performing a series of operations (possibly zero) on an array, all while avoiding negative values.

Formally, given an array sequenceData of size n of positive integers, the Analysts can perform the following operation any number of times (possibly zero):

  • Choose a prefix of size s (1 <= s <= n) that doesn't contain any zero (there is no index i such that sequenceData[i] = 0 and 1 \le i \le s).
  • Decrease all values of this prefix by one, i.e., set sequenceData[i] = sequenceData[i] - 1 for all 1 <= i <= s.

Find the maximum number of zeroes that the array sequenceData can contain after performing any (possibly zero) number of operations on the array.

 


Question 2: Word Conjugates

Problem Statement:

Amazon has introduced an innovative tool to explore the fascinating world of "Word Conjugates", allowing users to analyze strings consisting of only characters: 'a', 'b', 'c', and 'd'.

The concept of conjugates follows a unique pairing mechanism where 'a' pairs with 'b', 'c' pairs with 'd' and vice-versa. As a result, there are only four possible valid conjugate pairs: ('a', 'b'), ('b', 'a'), ('c', 'd'), and ('d', 'c').

The objective is to calculate the total number of valid substrings in a given string s.

A string is considered valid if:

  • There exists a permutation of the string such that the original string and its permutation are conjugates of each other.
  • Two strings s and t of the same length say n are considered conjugates if, for every index i (0 <= i < n), the pair formed by the characters at that index (s[i], t[i]) must be a conjugate pair.
ADD COMMENTlink 6 hours ago Rohit • 20

Login before adding your answer.

Similar Posts
Loading Similar Posts