Maximize count of planes that can be stopped per second with help of given initial position and speed | Function to find maximum number of planes that can be stopped from landing ; Stores the times needed for landing for each plane ; Iterate over the arrays ; Stores the time needed for landing of current plane ; Update the value of t ; Append the t in set St ; Return the answer ; Driver Code
function maxPlanes ( A , B ) { let St = new Set ( ) ; for ( let i = 0 ; i < A . length ; i ++ ) { let t = ( A [ i ] % B [ i ] > 0 ) ? 1 : 0 ; t += Math . floor ( A [ i ] / B [ i ] ) + t ; St . add ( t ) ; } return St . size ; } let A = [ 1 , 3 , 5 , 4 , 8 ] ; let B = [ 1 , 2 , 2 , 1 , 2 ] ; document . write ( maxPlanes ( A , B ) ) ;