1.You have n buses operating out of a city. You’ll be given an array “times” which denotes the number of days needed for the bus to complete the trip. You’ll also be given “totalTrips” which is the number of trips all the buses have to complete. You’ll need to return the minimum number of days needed for all the buses to complete totalTrips together.

Example 1 times = [1,2,3], totalTrips = 5 minimum no of days required - 3
Example 2 times = [2], totalTrips = 2 minimum no of days required - 4

  1. Given an array A of n numbers and you’ll also be given a positive integer k. You need to find the longest subarray such that the absolute difference of any two elements in the subarray is <= k.

Ex input : A = [8,2,4,3,7], k = 3

Ex output : 2

Comments (3)