Skip to content

Commit

Permalink
fix: cpp code
Browse files Browse the repository at this point in the history
  • Loading branch information
yanglbme committed Jun 23, 2024
1 parent 0c4be32 commit e42cac0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,18 @@ class Solution {

```cpp
class Solution {
public int minimumOperations(int[] nums) {
public:
int minimumOperations(vector<int>& nums) {
int ans = 0;
for (int x : nums) {
int mod = x % 3;
if (mod != 0) {
ans += Math.min(mod, 3 - mod);
if (mod) {
ans += min(mod, 3 - mod);
}
}
return ans;
}
}
};
```
#### Go
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,17 +100,18 @@ class Solution {

```cpp
class Solution {
public int minimumOperations(int[] nums) {
public:
int minimumOperations(vector<int>& nums) {
int ans = 0;
for (int x : nums) {
int mod = x % 3;
if (mod != 0) {
ans += Math.min(mod, 3 - mod);
if (mod) {
ans += min(mod, 3 - mod);
}
}
return ans;
}
}
};
```
#### Go
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
class Solution {
public int minimumOperations(int[] nums) {
public:
int minimumOperations(vector<int>& nums) {
int ans = 0;
for (int x : nums) {
int mod = x % 3;
if (mod != 0) {
ans += Math.min(mod, 3 - mod);
if (mod) {
ans += min(mod, 3 - mod);
}
}
return ans;
}
}
};

0 comments on commit e42cac0

Please sign in to comment.