Tap here to switch tabs
Problem
Submissions

Problem: Most Beautiful Item for Each Query

med
30 min
Try to solve the Most Beautiful Item for Each Query problem.

Statement

You are given a two dimensional integer array items, where items[i] = [‘extpricei‘,‘extbeautyi‘][` ext{price}_i`, ` ext{beauty}_i`] represents the price and beauty of an item.

You are also given an integer array queries. For each query queries[j], determine the maximum beauty among all items whose price is less than or equal to queries[j]. If no item has a price less than or equal to queries[j], the answer for that query is 00.

Return an array answer of the same length as queries where answer[j] is the answer to the jextthj^{ ext{th}} query.

Constraints:

  • 1≤1 \leq items.length, queries.length ≤105\leq 10^5

  • items[i].length =2= 2

  • 1≤1 \leq price_i, beauty_i, queries[j] ≤109\leq 10^9

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Most Beautiful Item for Each Query

med
30 min
Try to solve the Most Beautiful Item for Each Query problem.

Statement

You are given a two dimensional integer array items, where items[i] = [‘extpricei‘,‘extbeautyi‘][` ext{price}_i`, ` ext{beauty}_i`] represents the price and beauty of an item.

You are also given an integer array queries. For each query queries[j], determine the maximum beauty among all items whose price is less than or equal to queries[j]. If no item has a price less than or equal to queries[j], the answer for that query is 00.

Return an array answer of the same length as queries where answer[j] is the answer to the jextthj^{ ext{th}} query.

Constraints:

  • 1≤1 \leq items.length, queries.length ≤105\leq 10^5

  • items[i].length =2= 2

  • 1≤1 \leq price_i, beauty_i, queries[j] ≤109\leq 10^9