Breaking Chocolate Bars — Puzzle for Interview rounds

Question :

You have a bar of chocolate that consists of n x m square blocks.

If you can only break one piece at a time, how many breaks are necessary to break the original n x m piece into n*m 1 x 1 pieces?

How many are sufficient?

Solution :

Since every break creates exactly one new piece, n * m - 1 breaks are both necessary and sufficient to create n * m total pieces.

Thanks for Reading

Placewit grows the best engineers by providing an interactive classroom experience and by helping them develop their skills and get placed in amazing companies.

Learn more at Placewit. Follow us on Instagram and Facebook for daily learning.

--

--

--

Upskilling students for tech placements!

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

[Leetcode] Binary Tree Maximum Path Sum

The Pragmatic Programmer EP.5 — Imperfect Software

Advantages and Disadvantages of Tuple in Python

First-Class Functions

Software development life cycle: roles

Continuous Integration for a Mainframe App

Simplify Your CI Pipeline Configuration with Jsonnet

5 Principles Will Make your Code Robust

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Placewit

Placewit

Upskilling students for tech placements!

More from Medium

Google Interview Question — LeetCode 1423

Roman to Integer — Leetcode #13

Designing an Engineering Take Home Assignment — Part A

A pen lying on a white sheet of paper with some equations on it

Leetcode Solutions — 2Sums