hens and grains in non-decreasing order.t in the binary search, check if it is possible for the hens to finish all grains within t seconds using the greedy approach.hens array and use a pointer g to track the position of the left-most remaining grain.t.g.true; otherwise, return false.t required for all hens to finish the grains.