Tap here to switch tabs
Problem
Submissions

Problem: Most Beautiful Item for Each Query

Most Beautiful Item for Each Query asks you to find the maximum beauty among items priced within each query's limit, returning zero when no item is affordable.

Statement

You are given a two dimensional integer array items, where items[i] = [‘pricei‘,‘beautyi‘][` {price}_i`, ` {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 jthj^{ {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

Most Beautiful Item for Each Query asks you to find the maximum beauty among items priced within each query's limit, returning zero when no item is affordable.

Statement

You are given a two dimensional integer array items, where items[i] = [‘pricei‘,‘beautyi‘][` {price}_i`, ` {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 jthj^{ {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