Skip to content

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

Peponks9
Copy link

@Peponks9 Peponks9 commented Aug 5, 2025

Summary

This PR adds Rust implementations for algorithms as in the python3/Hash Maps and Sets directory.

Algorithms Implemented

  1. zero_striping.rs - Matrix zeroing using first row/column as markers
  2. zero_striping_hash_sets.rs - Matrix zeroing using hash sets for tracking
  • Consistency: Maintains same algorithmic logic as Python versions

Checklist

  • Missing algorithms will be submitted here.

José Velázquez and others added 3 commits August 2, 2025 18:41
- 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>>) {
Copy link
Collaborator

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 {
Copy link
Collaborator

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] {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Author

@Peponks9 Peponks9 left a 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
Copy link
Collaborator

@Destiny-02 Destiny-02 left a 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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make the comment closer to the original comment
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants