Skip to content

Commit f84f158

Browse files
solves #2481: Minimum Cuts to Divide a Circle in java
1 parent 00cced9 commit f84f158

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -782,7 +782,7 @@
782782
| 2466 | [Count Ways To Build Good Strings](https://leetcode.com/problems/count-ways-to-build-good-strings) | | |
783783
| 2469 | [Convert the Temperature](https://leetcode.com/problems/convert-the-temperature) | [![Java](assets/java.png)](src/ConvertTheTemperature.java) | |
784784
| 2475 | [Number of Unequal Triplets in Array](https://leetcode.com/problems/number-of-unequal-triplets-in-array) | [![Java](assets/java.png)](src/NumberOfUnequalTripletsInArray.java) | |
785-
| 2481 | [Minimum Cuts to Divide a Circle](https://leetcode.com/problems/minimum-cuts-to-divide-a-circle) | | |
785+
| 2481 | [Minimum Cuts to Divide a Circle](https://leetcode.com/problems/minimum-cuts-to-divide-a-circle) | [![Java](assets/java.png)](src/MinimumCutsToDivideACircle.java) | |
786786
| 2485 | [Find the Pivot Integer](https://leetcode.com/problems/find-the-pivot-integer) | | |
787787
| 2490 | [Circular Sentence](https://leetcode.com/problems/circular-sentence) | | |
788788
| 2492 | [Minimum Score of a Path Between Two Cities](https://leetcode.com/problems/minimum-score-of-a-path-between-two-cities) | [![Python](assets/python.png)](python/minimum_score_of_a_path_between_two_cities.py) | |

src/MinimumCutsToDivideACircle.java

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// https://leetcode.com/problems/minimum-cuts-to-divide-a-circle
2+
// T: O(1)
3+
// S: O(1)
4+
5+
public class MinimumCutsToDivideACircle {
6+
public int numberOfCuts(int n) {
7+
if (n == 1) return 0;
8+
return n % 2 == 0 ? n / 2 : n;
9+
}
10+
}

0 commit comments

Comments
 (0)