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 eachxiis the price of one bottle in storei. - An array of coins Bob can spend each day:
coins = [m1, m2, m3, ..., mq]where eachmirepresents the coins Bob can spend on thei-thday.
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
C++
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat