You are riding a bus, suppose in the East direction (bus direction will not change). Given the capacity of bus ‘c’ and an array such that [numberOfPassengers, PickUpLocation, DropLocation]. Check if you can drop all the passengers at their destinations. Return true or false
eg:
a. Bus capacity, c=4
[[3,1,5],[2,2,6]] -> Return false
Explanation: Bus capacity is 4. You pick 3 passengers at location 1, then your bus capacity will be 4-3=1. Now at location 2, two more passengers are waiting but your capacity is 1 so you can’t pick 2 passengers. Hence, dropping all passengers at their destinations is not possible.
b. Bus capacity, c=11
[[3,2,7],[3,7,9],[8,3,9]] -> Return true
Explanation:
Capacity:11
At location 2: Passengers = 3, Capacity = 11-3=8 (They will be drop at location 7)
At location 3: Passengers = 8, Capacity = 8-8 =0 (They will be drop at location 9)
At location 7: 3 people will be dropped, Capacity = 0+3=3,
Passengers=3, New capacity = 3-3=0 (They will be drop at location 9)
At location 9: All 11 passengers will be dropped (8+3).
Hence, you pick all passengers and drop them all. Return true.
Given an array, count pairs such that (arr[i]+arr[j])%60==0
eg. [30,20,150,100,40]
Output: 3
Explaination : (30+150) = 180 % 60 == 0 , Count=1
(20+100) = 120 % 60 == 0 , Count =2
(20+40) = 60 % 60 ==0, Count =3