FastPrepFastPrep
Problem Brief

Adjust Prices 🍱

NEW GRADOA

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
  • GG, spike! Ω©(^α—œ^ )و Β΄-

    1Example 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.

    2Example 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

    Limits and guarantees your solution can rely on.

    Unknown for now 🍭
    public int[] adjustPrices(int[] price, int[][] queries) {
      // write your code here
    }
    
    Input

    price

    [5, 7, 2]

    queries

    [[2, 6, 6]]

    Output

    [6, 7, 6]

    Sign in to submit your solution.