Follower count ranges

Write code · Medium · §8.1 Searching a sorted list

followers holds the number of followers of each account. The follower counts are in no particular order.

ranges holds the follower ranges that advertisers are looking for. An element [lo, hi] of ranges means the advertiser wants accounts with at least lo and at most hi followers. Complete the function solution, which returns a list of how many such accounts there are for each condition, in the same order as ranges.

Function

solution(followers, ranges)

Constraints

Examples

followersrangesresult
[27000, 9900, 1500, 780, 5200, 15000, 560][[5000, 25000], [3000, 8000]][3, 1]
[1300, 220, 900, 480, 150][[200, 700], [300, 2300]][2, 3]

Starter code

def solution(followers, ranges):
    answer = []
    return answer

Solve this problem in your browser

Python runs in your browser and checks your answer right away. Hints and the answer are on the problem page.