In this post, we are going to discuss leetcode 1231 — Divide Chocolate, which is asked in Google, Meta, and Amazon interviews.
Problem Analysis
You have one chocolate bar that consists of some chunks. Each chunk has its own sweetness given by the array
sweetness
.You want to share the chocolate with your
k
friends so you start cutting the chocolate bar intok + 1
pieces usingk
cuts, each piece consists of some consecutive chunks.