Problem Β· Array
Adjust Prices π±
A general store at hackerland sells n items with the price of the ith item represented by price[i]. The store adjusts the price of the items based on inflation as queries of two types:
- 1.
1 x v: change the price of thexth item tov. - 2.
2 v v: change any price that is less thanvtov.
Given an array price of n integers and the price adjustment queries are in the form of a 2-d array where query[i] consists of 3 integers, find the final prices of all the items.
Function Description:
Complete the func adjustPrices in the editor π
adjustPrices has the following parameter(s):
int price[n]: an arr of integersint queries[q][3]: A 2-d arr of intsGG, spike! Ω©(^α^ )Ω Β΄-
Examples
01 Β· Example 1
price = [5, 7, 2] queries = [[2, 6, 6]] return = [6, 7, 6]
The result would be
[6, 7, 6] since you update the 5 and the 2 as they are less than 6.02 Β· Example 2
price = [7, 5, 4] queries = [[2, 6, 6], [1, 2, 9], [2, 8, 8]] return = [8, 9, 8]
[2, 6, 6] - change elements < 6 to 6. now arr = [7, 6, 6]
[1, 2, 9] - change the second element to 9, arr = [7, 9 6]
[2, 8, 8] - change elements < 8 to 8. Finally arr = [8, 9, 8]
Constraints
Unknown for now πMore DoorDash problems
- Maximize Total Profit by Assigning Chefs to DishesPHONE SCREEN Β· Seen May 2026
- Closest DashMartPHONE SCREEN Β· Seen Jun 2025
- Return Priority of Order IDsPHONE SCREEN Β· Seen Jun 2025
- Discount EventsSeen Oct 2024
- Team FormationSeen Oct 2024
- Calculate Difference Value π§Seen Mar 2024
- Get Sizes of Friends Groups π₯Seen Mar 2024
public int[] adjustPrices(int[] price, int[][] queries) {
// write your code here
}
price[5, 7, 2]
queries[[2, 6, 6]]
expected[6, 7, 6]
sign in to submit