C # implementation for the above approach
using System ; using System . Linq ; public class GFG { static bool check ( int [ ] bananas , int mid_val , int H ) { int time = 0 ; for ( int i = 0 ; i < bananas . Length ; i ++ ) {