-
Notifications
You must be signed in to change notification settings - Fork 121
Add rust hash maps and sets #96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Add rust hash maps and sets #96
Conversation
- Add largest_container_brute_force.rs - Add next_lexicographical_sequence.rs - Add pair_sum_sorted_brute_force.rs - Add triplet_sum_brute_force.rs Completes the Rust Two Pointers implementation to match Python3 structure
@@ -0,0 +1,34 @@ | |||
use std::collections::HashSet; | |||
|
|||
pub fn zero_striping_hash_sets(matrix: &mut Vec<Vec<i32>>) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should it be fn
instead of pub fn
? Same for zero_striping.ts
.
// non-increasing order. Start searching from the second-to-last position. | ||
let mut pivot = letters.len() - 2; | ||
while pivot < letters.len() && letters[pivot] >= letters[pivot + 1] { | ||
if pivot == 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The while-loop implementation looks slightly different to the python implementation
|
||
// If pivot is not found, the string is already in its largest permutation. In | ||
// this case, reverse the string to obtain the smallest permutation. | ||
if pivot == 0 && letters[pivot] >= letters[pivot + 1] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes made and i'm about to submit two more solutions
…e_numbers_brute_force Rust implementations
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see comments. The comments from last time are still unresolved - did you push the changes yet?
use std::collections::HashMap; | ||
|
||
fn geometric_sequence_triplets(nums: Vec<i32>, r: i32) -> i32 { | ||
// Use HashMap to track frequencies, with default value of 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary
This PR adds Rust implementations for algorithms as in the
python3/Hash Maps and Sets
directory.Algorithms Implemented
Checklist