Skip to content

Commit d658404

Browse files
solves #3190: Find Minimum Operations to Make All Elements Divisible by Three in java
1 parent e718e71 commit d658404

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

Diff for: README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -919,7 +919,7 @@
919919
| 3174 | [Clear Digits](https://leetcode.com/problems/clear-digits) | [![Java](assets/java.png)](src/ClearDigits.java) | |
920920
| 3178 | [Find the Child Who Has the Ball After K Seconds](https://leetcode.com/problems/find-the-child-who-has-the-ball-after-k-seconds) | [![Java](assets/java.png)](src/FindTheChildWhoHasTheBallAfterKSeconds.java) | |
921921
| 3184 | [Count Pairs That Form a Complete Day I](https://leetcode.com/problems/count-pairs-that-form-a-complete-day-i) | [![Java](assets/java.png)](src/CountPairsThatFormACompleteDayI.java) | |
922-
| 3190 | [Find Minimum Operations to Make All Elements Divisible by Three](https://leetcode.com/problems/find-minimum-operations-to-make-all-elements-divisible-by-three) | | |
922+
| 3190 | [Find Minimum Operations to Make All Elements Divisible by Three](https://leetcode.com/problems/find-minimum-operations-to-make-all-elements-divisible-by-three) | [![Java](assets/java.png)](src/FindMinimumOperationsToMakeAllElementsDivisibleByThree.java) | |
923923
| 3194 | [Minimum Average of Smallest and Largest Elements](https://leetcode.com/problems/minimum-average-of-smallest-and-largest-elements) | | |
924924
| 3199 | [Count Triplets With Even XOR Set Bits I](https://leetcode.com/problems/count-triplets-with-even-xor-set-bits-i) | | |
925925
| 3200 | [Maximum Height of a Triangle](https://leetcode.com/problems/maximum-height-of-a-triangle) | | |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// https://leetcode.com/problems/find-minimum-operations-to-make-all-elements-divisible-by-three
2+
// T: O(N)
3+
// S: O(1)
4+
5+
public class FindMinimumOperationsToMakeAllElementsDivisibleByThree {
6+
public int minimumOperations(int[] array) {
7+
int minOperations = 0;
8+
for (int element : array) {
9+
if (element % 3 != 0) {
10+
minOperations++;
11+
}
12+
}
13+
return minOperations;
14+
}
15+
}

0 commit comments

Comments
 (0)