2 hours to solve two problems:
- Transaction Segments
Given an array transactionValues of length n, where transactionValues[i] is the transaction amount at time i.
Count the number of contiguous subarrays that are strictly increasing and have length exactly k.
Strictly increasing means: transactionValues[i] < transactionValues[i+1] < ... < transactionValues[i+k-1], i.e., every element must be strictly greater than the one before it.
- Efficient Tasks
Given an array difficulty of length n, where difficulty[i] is the difficulty of the i-th software module.
All modules must be assigned to 3 servers, subject to:
- Each server must get at least one module
- Each module is assigned to exactly one server
After the assignment, pick one module from each server (any module) and compute:
|d1 - d2| + |d2 - d3|
where d1, d2, d3 are the difficulties of the chosen modules from the three servers respectively.
The task: over all valid ways of assigning modules to the three servers, and for each assignment considering all choices of one module per server that minimize the formula, find the maximum of these minimum values.
Discussion
Loading comments…