Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 74e0b6f

Browse files
committed
Apply cargo clippy --fix
1 parent 35035b2 commit 74e0b6f

File tree

10 files changed

+22
-24
lines changed

10 files changed

+22
-24
lines changed

‎src/leetcode/contest/biweekly_63.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ impl Solution2 {
4242
}
4343
}
4444

45-
returncount_aaa > count_bbb;
45+
count_aaa > count_bbb
4646
}
4747
}
4848

‎src/leetcode/contest/weekly_262.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ impl Solution1 {
3939
// https://leetcode.com/problems/minimum-operations-to-make-a-uni-value-grid/
4040
impl Solution2 {
4141
pub fn min_operations(grid: Vec<Vec<i32>>, x: i32) -> i32 {
42-
let mut nums = grid.iter().flatten().map(|n| *n).collect::<Vec<i32>>();
42+
let mut nums = grid.iter().flatten().copied().collect::<Vec<i32>>();
4343

4444
let min = nums.iter().min().unwrap();
4545
for i in 0..nums.len() {

‎src/leetcode/interview/amazon/high_five.rs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ impl Solution {
1010
let mut ans: Vec<Vec<i32>> = vec![];
1111
for item in items.iter() {
1212
let [id, score] = [item[0], item[1]];
13-
if five_map.contains_key(&id) {
14-
five_map.entry(id).and_modify(|h| h.push(-score));
13+
if let std::collections::hash_map::Entry::Vacant(e) = five_map.entry(id) {
14+
e.insert(BinaryHeap::from(vec![-score]));
1515
} else {
16-
five_map.insert(id,BinaryHeap::from(vec![-score]));
16+
five_map.entry(id).and_modify(|h| h.push(-score));
1717
}
1818

1919
if five_map.get_mut(&id).unwrap().len() > 5 {

‎src/leetcode/interview/amazon/minimum_cost.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ impl Solution {
3535
}
3636
}
3737

38-
let mut weights = connections.clone(); // [x_i, y_i, cost_i]
38+
let mut weights = connections; // [x_i, y_i, cost_i]
3939
weights.sort_unstable_by(|a, b| a[2].cmp(&b[2]));
4040

4141
let mut costs = 0;

‎src/leetcode/interview/amazon/search.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ impl Solution {
77

88
let i = nums.binary_search_by(|p| p.0.cmp(&target));
99
match i {
10-
Ok(i) => returnnums[i].1 as i32,
11-
Err(_) => return-1,
10+
Ok(i) => nums[i].1 as i32,
11+
Err(_) => -1,
1212
}
1313
}
1414
}

‎src/leetcode/problem/bst_from_preorder.rs‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@ impl Solution {
3535
*i += 1;
3636

3737
let root = Rc::new(RefCell::new(TreeNode::new(val)));
38-
root.borrow_mut().left = helper(i, &preorder, lower, val);
39-
root.borrow_mut().right = helper(i, &preorder, val, upper);
38+
root.borrow_mut().left = helper(i, preorder, lower, val);
39+
root.borrow_mut().right = helper(i, preorder, val, upper);
4040

41-
returnSome(root);
41+
Some(root)
4242
}
4343

4444
let mut i = 0;
45-
returnhelper(&mut i, &preorder, i32::MIN, i32::MAX);
45+
helper(&mut i, &preorder, i32::MIN, i32::MAX)
4646
}
4747
}
4848

‎src/leetcode/problem/diameter_of_binary_tree.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ impl Solution {
3232
let path_length = 1 + path_left + path_right;
3333
*max_path_length = i32::max(*max_path_length, path_length);
3434

35-
return1 + i32::max(path_left, path_right);
35+
1 + i32::max(path_left, path_right)
3636
}
3737

3838
let mut max_path_length = 0;

‎src/leetcode/problem/merge.rs‎

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,14 @@ impl Solution {
77
let mut ans: Vec<Vec<i32>> = vec![];
88

99
for interval in intervals.iter_mut() {
10-
if ans.len() == 0 {
10+
if ans.is_empty() {
1111
ans.push(interval.clone());
12+
} else if interval[0] >= ans.last().unwrap()[0] && interval[1] <= ans.last().unwrap()[1] {
13+
continue;
14+
} else if interval[0] <= ans.last().unwrap()[1] {
15+
ans.last_mut().unwrap()[1] = interval[1];
1216
} else {
13-
if interval[0] >= ans.last().unwrap()[0] && interval[1] <= ans.last().unwrap()[1] {
14-
continue;
15-
} else if interval[0] <= ans.last().unwrap()[1] {
16-
ans.last_mut().unwrap()[1] = interval[1];
17-
} else {
18-
ans.push(interval.clone());
19-
}
17+
ans.push(interval.clone());
2018
}
2119
}
2220

‎src/leetcode/problem/rob.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ impl Solution {
3333
}
3434
}
3535

36-
i32::max(bfs(root.clone()).0, bfs(root.clone()).1)
36+
i32::max(bfs(root.clone()).0, bfs(root).1)
3737
}
3838
}
3939

‎src/leetcode/problem/trap.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ impl Solution {
88
let mut q = VecDeque::<usize>::new();
99

1010
for (i, h) in height.iter().enumerate() {
11-
while q.len() > 0 && height[*q.back().unwrap()] < *h {
11+
while !q.is_empty() && height[*q.back().unwrap()] < *h {
1212
let top = q.pop_back().unwrap();
13-
if q.len() == 0 {
13+
if q.is_empty() {
1414
break;
1515
}
1616

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /