Skip to content

Commit 3785d82

Browse files
solves problem 453
1 parent 3195faf commit 3785d82

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
| 21 | [Merge 2 Sorted Lists](https://leetcode.com/problems/merge-two-sorted-lists/) | Easy | [![Java](https://img.icons8.com/color/40/000000/java-coffee-cup-logo.png)](https://github.com/anishLearnsToCode/leetcode-algorithms/blob/master/src/Merge2SortedLists.java) |
1818
| 26 | [Remove Duplicates From Sorted Array](https://leetcode.com/problems/remove-duplicates-from-sorted-array/) | Easy | [![Java](https://img.icons8.com/color/40/000000/java-coffee-cup-logo.png)](https://github.com/anishLearnsToCode/leetcode-algorithms/blob/master/src/RemoveDuplicatesFromSortedArray.java) |
1919
| 27 | [Remove Element](https://leetcode.com/problems/remove-element/) | Easy | [![Java](https://img.icons8.com/color/40/000000/java-coffee-cup-logo.png)](https://github.com/anishLearnsToCode/leetcode-algorithms/blob/master/src/RemoveElement.java) [![Python](https://img.icons8.com/color/35/000000/python.png)](https://github.com/anishLearnsToCode/leetcode-algorithms/blob/master/python/remove_element.py)|
20-
| 28 | [Needle in Haystack](https://leetcode.com/problems/implement-strstr) | Easy | [![Java](https://img.icons8.com/color/40/000000/java-coffee-cup-logo.png)](https://github.com/anishLearnsToCode/leetcode-algorithms/blob/master/src/NeedleInHaystack.java) [![Python](https://img.icons8.com/color/35/000000/python.png)](https://github.com/anishLearnsToCode/leetcode-algorithms/blob/master/python/needle_in_haystack.py)|
20+
| 28 | [Needle in Haystack](https://leetcode.com/problems/implement-strstr) | Easy | [![Java](https://img.icons8.com/color/40/000000/java-coffee-cup-logo.png)](https://github.com/anishLearnsToCode/leetcode-algorithms/blob/master/src/NeedleInHaystack.java) [![Python](https://img.icons8.com/color/35/000000/python.png)](https://github.com/anishLearnsToCode/leetcode-algorithms/blob/master/python/needle_in_haystack.py) |
2121
| 35 | [Search Inserted Position](https://leetcode.com/problems/search-insert-position/) | Easy | [![Java](https://img.icons8.com/color/40/000000/java-coffee-cup-logo.png)](https://github.com/anishLearnsToCode/leetcode-algorithms/blob/master/src/SearchInsertPosition.java) |
2222
| 38 | [Count and Say](https://leetcode.com/problems/count-and-say) | Easy | [![Java](https://img.icons8.com/color/40/000000/java-coffee-cup-logo.png)](https://github.com/anishLearnsToCode/leetcode-algorithms/blob/master/src/CountAndSay.java) |
2323
| 53 | [Maximum SubArray](https://leetcode.com/problems/maximum-subarray) | Easy | [![Java](https://img.icons8.com/color/40/000000/java-coffee-cup-logo.png)](https://github.com/anishLearnsToCode/leetcode-algorithms/blob/master/src/MaximumSubArray.java) |
@@ -118,7 +118,7 @@
118118
| 443 | [String Compression](https://leetcode.com/problems/string-compression) | Easy | [![Java](https://img.icons8.com/color/40/000000/java-coffee-cup-logo.png)](https://github.com/anishLearnsToCode/leetcode-algorithms/blob/master/src/StringCompression.java) |
119119
| 447 | [Number of Boomerangs](https://leetcode.com/problems/number-of-boomerangs) | Easy | [![Java](https://img.icons8.com/color/40/000000/java-coffee-cup-logo.png)](https://github.com/anishLearnsToCode/leetcode-algorithms/blob/master/src/NumberOfBoomerangs.java) |
120120
| 448 | [Find All Numbers Disappeared in an Array](https://leetcode.com/problems/find-all-numbers-disappeared-in-an-array) | Easy | [![Java](https://img.icons8.com/color/40/000000/java-coffee-cup-logo.png)](src/FindAllNumbersDisappearedInAnArray.java) |
121-
| 453 | [Minimum Moves to Equal Array Elements](https://leetcode.com/problems/minimum-moves-to-equal-array-elements) | Easy | |
121+
| 453 | [Minimum Moves to Equal Array Elements](https://leetcode.com/problems/minimum-moves-to-equal-array-elements) | Easy | [![Java](https://img.icons8.com/color/40/000000/java-coffee-cup-logo.png)](src/MinimumMovesToEqualArrayElements.java) [![Python](https://img.icons8.com/color/35/000000/python.png)](python/minimum_moves_to_equal_array_element.py) |
122122
| 455 | [Assign Cookies](https://leetcode.com/problems/assign-cookies) | Easy | |
123123
| 459 | [Repeated Substring Pattern](https://leetcode.com/problems/repeated-substring-pattern) | Easy | |
124124
| 461 | [Hamming Distance](https://leetcode.com/problems/hamming-distance) | Easy | |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from typing import List
2+
3+
4+
class Solution:
5+
def minMoves(self, nums: List[int]) -> int:
6+
minValue = min(nums)
7+
return sum(nums) - minValue * len(nums)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import java.util.Arrays;
2+
3+
public class MinimumMovesToEqualArrayElements {
4+
public int minMoves(int[] nums) {
5+
int sum = Arrays.stream(nums).sum();
6+
int minimumValue = Arrays.stream(nums).min().getAsInt();
7+
return sum - minimumValue * nums.length;
8+
}
9+
}

0 commit comments

Comments
 (0)