Skip to content

Commit 6686e71

Browse files
Merge 4c10ad8 into 6c947ea
2 parents 6c947ea + 4c10ad8 commit 6686e71

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,14 @@ cargo test
7272
0411 | [~~Minimum Unique Word Abbreviation~~](https://leetcode.com/problems/minimum-unique-word-abbreviation/) | [C++](https://github.com/kamyu104/LeetCode-Solutions/blob/master/C++/minimum-unique-word-abbreviation.cpp) [Python](https://github.com/kamyu104/LeetCode-Solutions/blob/master/Python/minimum-unique-word-abbreviation.py) | _O(2^n)_ | _O(n)_ | Hard | 🔒 |
7373
0421 | [Maximum XOR of Two Numbers in an Array](https://leetcode.com/problems/maximum-xor-of-two-numbers-in-an-array/) | [C++](https://github.com/kamyu104/LeetCode-Solutions/blob/master/C++/maximum-xor-of-two-numbers-in-an-array.cpp) [Python](https://github.com/kamyu104/LeetCode-Solutions/blob/master/Python/maximum-xor-of-two-numbers-in-an-array.py) <br>------</br> [Rust](./kamyu104/src/maximum_xor_of_two_numbers_in_an_array.rs) | _O(n)_ | _O(n)_ | Medium ||
7474
0461 | [Hamming Distance](https://leetcode.com/problems/hamming-distance/) | [C++](https://github.com/kamyu104/LeetCode-Solutions/blob/master/C++/hamming-distance.cpp) [Python](https://github.com/kamyu104/LeetCode-Solutions/blob/master/Python/hamming-distance.py) <br>------</br> [Rust](./kamyu104/src/hamming_distance.rs) | _O(1)_ | _O(1)_ | Easy ||
75+
0462 | [Minimum Moves to Equal Array Elements II](https://leetcode.com/problems/minimum-moves-to-equal-array-elements-ii/) | [C++](https://github.com/kamyu104/LeetCode-Solutions/blob/master/C++/minimum-moves-to-equal-array-elements-ii.cpp) [Python](https://github.com/kamyu104/LeetCode-Solutions/blob/master/Python/minimum-moves-to-equal-array-elements-ii.py) <br>------</br> [Rust](./kamyu104/src/minimum_moves_to_equal_array_elements_ii.rs) | _O(n)_ on average | _O(1)_ | Medium ||
7576

7677
<!--
7778
7879
=======
7980
8081
<!--
8182
82-
0462 | [Minimum Moves to Equal Array Elements II](https://leetcode.com/problems/minimum-moves-to-equal-array-elements-ii/) | [C++](./C++/minimum-moves-to-equal-array-elements-ii.cpp) [Python](./Python/minimum-moves-to-equal-array-elements-ii.py) | _O(n)_ on average | _O(1)_ | Medium ||
8383
0477 | [Total Hamming Distance](https://leetcode.com/problems/total-hamming-distance/) | [C++](./C++/total-hamming-distance.cpp) [Python](./Python/total-hamming-distance.py) | _O(n)_ | _O(1)_ | Medium ||
8484
0645 | [Set Mismatch](https://leetcode.com/problems/set-mismatch/) | [C++](./C++/set-mismatch.cpp) [Python](./Python/set-mismatch.py) | _O(n)_ | _O(1)_ | Easy ||
8585
0693 | [Binary Number with Alternating Bits](https://leetcode.com/problems/binary-number-with-alternating-bits/) | [C++](./C++/binary-number-with-alternating-bits.cpp) [Python](./Python/binary-number-with-alternating-bits.py) | _O(1)_ | _O(1)_ | Easy ||

kamyu104/src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ mod find_the_difference;
44
mod hamming_distance;
55
mod maximum_product_of_word_lengths;
66
mod maximum_xor_of_two_numbers_in_an_array;
7+
mod minimum_moves_to_equal_array_elements_ii;
78
mod missing_number;
89
mod number_of_1_bits;
910
mod power_of_four;
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Time: O(n) on average
2+
// Space: O(1)
3+
4+
// Quick select solution.
5+
pub struct Solution {}
6+
impl Solution {
7+
pub fn min_moves2(nums: Vec<i32>) -> i32 {
8+
2
9+
}
10+
}
11+
12+
#[cfg(test)]
13+
mod tests {
14+
use super::*;
15+
16+
#[test]
17+
fn test_min_moves2() {
18+
assert_eq!(Solution::min_moves2(vec![1, 2, 3]), 2);
19+
}
20+
}

0 commit comments

Comments
 (0)