Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.

book
Bob and Fantastic Drink

Bob enjoys relaxing after a long day of work. Like many programmers, he's a fan of the famous drink Fantastic, which is sold at various stores around the city. The price of one bottle in store i is xi coins. Bob plans to buy the drink for q consecutive days, and for each day, he knows he will have mi coins to spend. On each day, Bob wants to know how many different stores he can afford to buy the drink from.

You are given two arrays:

  • An array of prices in the shops: prices = [x1, x2, x3, ..., xn] where each xi is the price of one bottle in store i.
  • An array of coins Bob can spend each day: coins = [m1, m2, m3, ..., mq] where each mi represents the coins Bob can spend on the i-th day.

Return number of shops where Bob will be able to buy a bottle of the drink on the i-th day.

Example 1

Input:

prices = [3,10,8,6,11]; coins = [1, 10, 3, 11]

Output:

[0, 4, 1, 5]
main.cpp

main.cpp

C++

Fråga AI

expand

Fråga AI

ChatGPT

Fråga vad du vill eller prova någon av de föreslagna frågorna för att starta vårt samtal

some-alt