C ++ implementation for the above approach
#include <bits/stdc++.h> NEW_LINE using namespace std ; bool check ( vector < int > & bananas , int mid_val , int H ) { int time = 0 ; for ( int i = 0 ; i < bananas . size ( ) ; i ++ ) {