Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit ddac1ec

Browse files
committed
fix
1 parent 06e1ec9 commit ddac1ec

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

kamyu104/src/binary_watch.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
use std::collections::BTreeSet;
22

3+
// Time: O(1)
4+
// Space: O(1)
5+
36
pub struct Solution {}
47
impl Solution {
58
pub fn read_binary_watch(num: i32) -> Vec<String> {
69
let mut result: Vec<String> = Vec::new();
710
(0..12).for_each(|h| {
811
(0..60).for_each(|m| {
912
if (Solution::bit_count(h) + Solution::bit_count(m)) == num {
10-
let elem = format!("{}:{:02}", h, m);
11-
result.push(elem);
13+
result.push(format!("{}:{:02}", h, m));
1214
}
1315
});
1416
});

kamyu104/src/single_number_iii.rs

+14-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use std::collections::BTreeSet;
2+
13
// Time: O(n)
24
// Space: O(1)
35

@@ -49,8 +51,18 @@ mod tests {
4951

5052
#[test]
5153
fn test_single_number() {
52-
assert_eq!(Solution1::single_number(vec![1, 2, 1, 3, 2, 5]), vec![5, 3]);
54+
assert_eq!(
55+
Solution1::single_number(vec![1, 2, 1, 3, 2, 5])
56+
.into_iter()
57+
.collect::<BTreeSet<i32>>(),
58+
vec![3, 5].into_iter().collect::<BTreeSet<i32>>()
59+
);
5360

54-
assert_eq!(Solution2::single_number(vec![1, 2, 1, 3, 2, 5]), vec![3, 5]);
61+
assert_eq!(
62+
Solution2::single_number(vec![1, 2, 1, 3, 2, 5])
63+
.into_iter()
64+
.collect::<BTreeSet<i32>>(),
65+
vec![3, 5].into_iter().collect::<BTreeSet<i32>>()
66+
);
5567
}
5668
}

0 commit comments

Comments
 (0)