Skip to content

Commit c26f67d

Browse files
committed
Runtime: 84 ms (Top 19.36%) | Memory: 28.2 MB (Top 98.61%)
1 parent 8e166a5 commit c26f67d

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed
Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1+
// Runtime: 84 ms (Top 19.36%) | Memory: 28.2 MB (Top 98.61%)
2+
13
class Solution {
24
public:
35
int minMoves(vector<int>& nums) {
4-
6+
57
// sorting the array to get min at the first
68
sort(nums.begin(), nums.end());
79
int cnt = 0, n = nums.size();
8-
10+
911
// Now we have to make min equal to every number and keep adding the count
1012
for(int i = 1; i < n; i++)
1113
cnt += nums[i] - nums[0];
12-
14+
1315
return cnt;
1416
}
15-
};
17+
};

0 commit comments

Comments
 (0)