Minimum Cuts to Divide a Circle - Problem
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.
Given the integer n, return the minimum number of cuts needed to divide a circle into n equal slices.
Input & Output
Example 1 — Four Equal Slices
$
Input:
n = 4
›
Output:
4
💡 Note:
To divide a circle into 4 equal slices, we need 4 cuts through the center. Each cut creates one slice boundary.
Example 2 — Single Slice
$
Input:
n = 1
›
Output:
0
💡 Note:
For 1 slice (the whole circle), no cuts are needed.
Example 3 — Three Equal Slices
$
Input:
n = 3
›
Output:
3
💡 Note:
To create 3 equal slices, we need 3 cuts, each at 120° angles from each other through the center.
Constraints
- 1 ≤ n ≤ 106
Visualization
Tap to expand
Understanding the Visualization
1
Input
Number of equal slices needed: n = 4
2
Process
Each cut creates one slice boundary
3
Output
Minimum cuts needed: 4
Key Takeaway
🎯 Key Insight: Each cut through the center creates exactly one slice boundary, so n slices require n cuts (except n=1 needs 0 cuts)
💡
Explanation
AI Ready
💡 Suggestion
Tab
to accept
Esc
to dismiss
// Output will appear here after running code