Description
Solutions
Adjust Prices π±
π©βπ NEW GRADπRELATED PROBLEMS
A general store at hackerland sells n
items with the price of the i
th 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 thex
th item tov
. - 2.
2 v v
: change any price that is less thanv
tov
.
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! Ω©(^α^ )Ω Β΄-
Example 1:
Input: price = [5, 7, 2], queries = [[2, 6, 6]]
Output: [6, 7, 6]
Explanation:The result would be[6, 7, 6]
since you update the5
and the2
as they are less than6
.
Example 2:
Input: price = [7, 5, 4], queries = [[2, 6, 6], [1, 2, 9], [2, 8, 8]]
Output: [8, 9, 8]
Explanation:[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 π


Related Problems
Testcase
Result
Case 1
input:
output: