[LeetCode] Minimum Cuts to Divide a Circle

2481. Minimum Cuts to Divide a Circle

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.

1
2
3
4
5
6
7
8
class Solution {
public:
int numberOfCuts(int n) {
if(n == 1) return 0;
if(n % 2 == 0) return n / 2;
return n;
}
};
Author: Song Hayoung
Link: https://songhayoung.github.io/2022/11/26/PS/LeetCode/minimum-cuts-to-divide-a-circle/
Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.