Description
Solutions
Submission
Adjust Prices 🍱
🔥 FULLTIME

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 the xth item to v.
  • 2. 2 v v: change any price that is less than v to v.

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 integers
  • int queries[q][3]: A 2-d arr of ints
  • 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 the 5 and the 2 as they are less than 6.

    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 🍭
    Thumbnail 0
    Thumbnail 1
    Testcase

    Result
    Case 1

    input:

    output: