left to 1 and right to the maximum value in the candies array.left is less than or equal to right:
a. Calculate mid as the average of left and right.
b. Check if it is possible to divide the piles into at least k sub piles of size mid.
c. If it is possible, update left to mid + 1 and set result to mid (potential answer).
d. If it is not possible, update right to mid - 1.result as the maximum number of candies per child.