This questions was asked in sharechat online assessment in Hackerearth.
Given a n chocolates with ith chocolate having si sweetness and ti expiry time. You are given Q (≤ 10^5) queries like (x, y), for each query return the number of chocolates whose sweetness greater than x and expiry time greater than y. (number of chocolates ≤ 10^5)?
For example:
chocolates - 5
sweetness - [1, 3, 6, 7, 2]
expire time-[10, 7, 2, 6, 4]
queries: 2
2 6
3 9
output:
1 // only 2nd chocolate
0 // none