[weride] OA General
  1. Question 1

Given n images to process, where each image requires specific filters applied for a defined time frame. The cost to apply filters to the iᵗʰ image is filterCost[i]. Each image must undergo processing from the start day, startDay[i], to the end day, endDayi, where 0 ≤ i < n.

There is an exclusive offer that a filter may be applied to all n images at a discounted rate, discountPrice, per day.

Devise a strategy to minimize costs and apply the necessary filters to each image during its designated processing period. The goal is to create an efficient image processing plan that adheres to time constraints and budget considerations. Return the minimum cost modulo (10⁹ + 7).

Example
Given n = 3, filterCost = [2, 3, 4], startDay = [1, 1, 2], endDay = [2, 3, 4] and discountPrice = 6.

DayImagesTotal Cost
1[1, 2]2 + 3 = 5
2[1, 2, 3]2 + 3 + 4 = 9
3[2, 3]3 + 4 = 7
4[3]4

Applying filters on all the images at 6 per day on the 2ⁿᵈ and 3ʳᵈ day will be optimal.

The modulo of the final cost is 5 + 6 + 6 + 4 = 21.

Function Description
Complete the function getMinProcessingCost in the editor below.


2. Question 2

A cyber attack involves different levels of security systems. The attack has n levels and can be initiated at any level l with an initial energy reserve of k. On an iᵗʰ level, the attack must breach the security system's layers[i] units of protection at a cost of layer[i] units of energy. If there is not enough energy left, the attack fails, and the attack ends. If after breaching an iᵗʰ level, the remaining energy reserve is at least energy[i], one point is awarded to the attacker.

Given the arrays layers and energy, and an integer k, starting from each level l from 1 to n, find the number of points that the attacker can score.


Example

Given, n = 3,
layers = [5, 8, 1],
energy = [4, 2, 1],
k = 10.

Start LevelAttack ProcessMax. Points
1Level 1: Energy Left = 10, layers = 5, Remaining Energy = 5 A point is awarded here as the required energy is at least 4. Level 2: Energy Left = 5, layers = 8 The attack fails as the attacker cannot breach a layer of 8 units. The attack beginning at level 1 ends.1
2Level 2: Energy Left = 10, layers = 8, Remaining Energy = 2 A point is awarded here as the required energy is at least 2. Level 3: Energy Left = 2, layers = 1, Remaining Energy = 1 A point is awarded here as the required energy is at least 1. The attack beginning at level 2 ends.2

我们长期稳定承接各大科技公司如TikTok、Google、Amazon等的OA笔试代写服务,确保满分通过。如有需求,请随时联系我们。

We consistently provide professional online assessment services for major tech companies like TikTok, Google, and Amazon, guaranteeing perfect scores. Feel free to contact us if you're interested.

Leave a Reply

Your email address will not be published. Required fields are marked *