Eating Candies

Image placeholder 9899

(This question has been seen in the interviews of the following companies: Tiktok)
Tiktok Online Assessment Questions

There are n candies put from left to right on a table. The candies are numbered from left to right. The i-th candy has weight candies[i]. Alice and Bob eat candies.
Alice can eat any number of candies from the left (she can't skip candies, she eats them in a row).
Bob can eat any number of candies from the right (he can't skip candies, he eats them in a row).
Of course, if Alice ate a candy, Bob can't eat it (and vice versa).
They want to be fair. Their goal is to eat the same total weight of candies. What is the most number of candies they can eat in total?

Signature
public int maxCandiesCount(int[] candies):

Example 1
candies:[1000]
There is only candy, and it is not possible for Alice and Bob to eat the same total weight. 

Example 2...





Get one-to-one training from Google Facebook engineers

Top-notch Professionals

Learn from Facebook and Google senior engineers interviewed 100+ candidates.
Most recent interview questions and system design topics gathered from aonecode alumnus.
One-to-one online classes. Get feedbacks from real interviewers.

Customized Private Class

Already a coding expert? - Advance straight to hard interview topics of your interest.
New to the ground? - Develop basic coding skills with your own designated mentor.
Days before interview? - Focus on most important problems in target company question bank.