Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/graph/lowest_common_ancestor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ mod tests {
}
}
let mut offline_answers = offline.answer_queries(1, &tree);
offline_answers.sort_unstable_by(|a1, a2| a1.query_id.cmp(&a2.query_id));
offline_answers.sort_unstable_by_key(|a| a.query_id);
assert_eq!(offline_answers, online_answers);
}
}
2 changes: 1 addition & 1 deletion src/greedy/job_sequencing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ pub fn schedule_jobs(mut jobs: Vec<Job>) -> ScheduleResult {
}

// Step 1 – sort jobs by profit, highest first.
jobs.sort_unstable_by(|a, b| b.profit.cmp(&a.profit));
jobs.sort_unstable_by_key(|a| std::cmp::Reverse(a.profit));

// Step 2 – allocate slots.
// At most n jobs can ever be scheduled, so cap the slot count at jobs.len()
Expand Down
2 changes: 1 addition & 1 deletion src/string/burrows_wheeler_transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub fn inv_burrows_wheeler_transform<T: AsRef<str>>(input: (T, usize)) -> String
table.push((i, input.0.as_ref().chars().nth(i).unwrap()));
}

table.sort_by(|a, b| a.1.cmp(&b.1));
table.sort_by_key(|a| a.1);

let mut decoded = String::new();
let mut idx = input.1;
Expand Down
3 changes: 1 addition & 2 deletions src/string/manacher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ pub fn manacher(s: String) -> String {
radius += 1;
// 2: Checking palindrome.
// Need to care about overflow usize.
while i >= radius && i + radius <= chars.len() - 1 && chars[i - radius] == chars[i + radius]
{
while i >= radius && i + radius < chars.len() && chars[i - radius] == chars[i + radius] {
length_of_palindrome[i] += 2;
radius += 1;
}
Expand Down