Skip to main content

Minimum Cuts to Divide a Circle - Solution & Explanation

EasyMathGeometry14 min readAsked at: Amazon, Microsoft, Google +2
Practice this problem

Problem Statement

A valid cut in a circle can be:

  • A cut that is represented by a straight line that touches two points on the edge of the circle and passes through its center, or
  • A cut that is represented by a straight line that touches one point on the edge of the circle and its center.

Some valid and invalid cuts are shown in the figures below.

Given the integer n, return the minimum number of cuts needed to divide a circle into n equal slices.

 

Example 1:

Input: n = 4
Output: 2
Explanation: 
The above figure shows how cutting the circle twice through the middle divides it into 4 equal slices.

Example 2:

Input: n = 3
Output: 3
Explanation:
At least 3 cuts are needed to divide the circle into 3 equal slices. 
It can be shown that less than 3 cuts cannot result in 3 slices of equal size and shape.
Also note that the first cut will not divide the circle into distinct parts.

 

Constraints:

  • 1 <= n <= 100

Approach Overview

Problem Overview: Given an integer n, determine the minimum number of straight cuts required to divide a circle into exactly n equal slices. Each cut is a straight line across the circle and can intersect previous cuts.

Approach 1: Iterative Simulation of Cuts (O(n) time, O(1) space)

This approach simulates the cutting process conceptually. Start from a single whole circle and reason about how many additional slices each new cut can produce. If you keep adding cuts one by one, you track the total pieces formed until reaching n. The logic relies on recognizing how a cut across the circle can create new regions depending on where it passes relative to previous cuts. While simple to reason about, this method still performs repeated checks or iterations up to n, making it less efficient than a direct formula.

The approach is useful for understanding the geometry behind the problem. It helps you visualize how slices increase as you add diameters or chords. However, since the relationship between cuts and slices follows a predictable pattern, simulation becomes unnecessary once the pattern is recognized.

Approach 2: Mathematical Calculation for Minimum Cuts (O(1) time, O(1) space)

The optimal solution comes from a simple geometric observation. If n == 1, no cuts are needed. When n is even, each cut can pass through the center (a diameter) and create two equal slices. With n/2 diameters, you get exactly n equal pieces. When n is odd, diameters alone cannot produce the required symmetry, so each slice requires its own cut, resulting in n cuts.

This reduces the problem to a constant-time formula: return 0 if n == 1, return n / 2 if n is even, otherwise return n. No loops, no data structures, and no geometric construction are required. The entire solution relies on recognizing the symmetry properties of circles and diameters.

The reasoning falls under basic Math and Geometry concepts, especially symmetry and equal partitioning of circular regions.

Recommended for interviews: The mathematical observation is what interviewers expect. It shows you can move from brute reasoning to pattern recognition and reduce the problem to an O(1) formula. Mentioning the simulation idea briefly demonstrates understanding of the geometry, but implementing the constant-time solution shows stronger problem-solving skill.

Approach 1: Mathematical Calculation for Minimum Cuts

When you have a circle, dividing it into n equal parts can be achieved depending on whether n is even or odd.

  • Even: When n is even, you can achieve this with n/2 cuts through the center because each cut through the center divides the circle into two equal parts.
  • Odd: When n is odd, each cut after the first one can pass through the center, adding one more section than the previous even count, so you must use n cuts.

In this Python solution, the key logic is whether n is even or odd. If n is even, dividing n by 2 gives the number of cuts needed. If n is odd, n cuts are required.

Code

Python

C

C++

Java

C#

JavaScript

Complexity

The time complexity is O(1) since the calculations involved are basic arithmetic operations. The space complexity is also O(1) because no additional data structures are used.

Try this approach in the editor →

Approach 2: Iterative Simulation of Cuts

This approach involves simulating the division by using iterations and manually counting the number of cuts. It covers each scenario by first considering it as a line that does not pass through the center of the circle, but subsequently confirms the equal division of the circle.

Start with 1 cut and multiply by 2 each time after incrementing. Repeat until the number of distinct segments is no less than n.

Code

Python

C

C++

Java

C#

JavaScript

Complexity

The while loop ensures that the computation quickly reaches a point , O(log n) time complexity and O(1) space complexity.

Try this approach in the editor →

Approach 3: Case Discussion

  • When n=1, no cutting is needed, so the number of cuts is 0;
  • When n is odd, there is no collinear situation, and at least n cuts are needed;
  • When n is even, they can be collinear in pairs, and at least \frac{n}{2} cuts are needed.

In summary, we can get:

$ ans = \begin{cases} n, & n \gt 1 and n is odd \ \frac{n}{2}, & n is even \ \end{cases}

The time complexity is O(1), and the space complexity is O(1)$.

Code

Python

Java

C++

Go

TypeScript

Rust

C#

Try this approach in the editor →

Complexity Comparison

ApproachComplexity
Mathematical Calculation for Minimum Cuts

The time complexity is O(1) since the calculations involved are basic arithmetic operations. The space complexity is also O(1) because no additional data structures are used.

Iterative Simulation of Cuts

The while loop ensures that the computation quickly reaches a point , O(log n) time complexity and O(1) space complexity.

Case Discussion—

Detailed Complexity Analysis

ApproachTimeSpaceWhen to Use
Iterative Simulation of CutsO(n)O(1)Useful for understanding how slices grow with each cut or when deriving the mathematical pattern
Mathematical CalculationO(1)O(1)Best choice for interviews and production solutions due to constant-time computation

Video Solution

2481. Minimum Cuts to Divide a Circle (Leetcode Easy) • Programming Live with Larry • 393 views views

Watch 9 more video solutions →

Frequently Asked Questions

Is Minimum Cuts to Divide a Circle easy or hard?
Minimum Cuts to Divide a Circle is classified as an Easy problem on LeetCode. The challenge is recognizing the mathematical pattern between the number of slices and the cuts required rather than implementing complex algorithms.
Minimum Cuts to Divide a Circle Python/Java solution
The implementation in Python, Java, C++, or JavaScript is very short. Check if n equals 1, return 0. If n is even return n/2, otherwise return n. Because the logic is constant time, the code typically fits within a few lines in any programming language.
How to solve Minimum Cuts to Divide a Circle in O(1)?
Check the value of n. If n equals 1, return 0. If n is even, return n/2 since each diameter cut produces two equal slices. If n is odd, return n because each slice effectively requires its own cut. This constant-time formula eliminates the need for simulation.
What is the best approach for Minimum Cuts to Divide a Circle?
The best approach is a mathematical observation that runs in O(1) time and O(1) space. If n equals 1, no cuts are needed. If n is even, n/2 diameter cuts create n equal slices. If n is odd, you need n cuts because diameters alone cannot produce an odd number of equal sections.
Is Minimum Cuts to Divide a Circle asked at Google/Amazon/Meta?
Problems based on mathematical observations and simple geometry frequently appear in coding interviews at companies like Google, Amazon, and Meta. While this exact problem may vary, recognizing patterns and reducing problems to O(1) formulas is a common interview expectation.
What data structure is used in Minimum Cuts to Divide a Circle?
No special data structure is required. The solution relies purely on mathematical reasoning and basic conditional checks, making it a Math and Geometry problem rather than a data structure problem.
What is the time complexity of Minimum Cuts to Divide a Circle?
The optimal solution runs in O(1) time and O(1) space because it uses a direct mathematical formula based on whether n is even or odd. No loops, recursion, or additional data structures are required.

Ready to solve this problem?

Practice Minimum Cuts to Divide a Circle with our built-in code editor and test cases.

Practice on FleetCode