Skip to content

Instantly share code, notes, and snippets.

View Hpmason's full-sized avatar
🦀

Mason Ginter Hpmason

🦀
View GitHub Profile
use std::{
alloc::{alloc_zeroed, dealloc, Layout},
ptr,
};
#[derive(Debug)]
/// ADT that represents Trie data structure
pub struct Trie<T> {
root: TrieNode<T>,
len: usize,
@Hpmason
Hpmason / spellcheck.rs
Created January 6, 2024 20:52
examples/spellcheck.rs
use std::{env, fs::read_to_string, path::PathBuf, process};
use structs_from_scratch::trie::Trie;
fn print_usage(exe_path: &PathBuf) {
let exe = exe_path.file_name().expect("can get filename");
println!("{} <dictionary> <txt_file>", exe.to_string_lossy());
}
fn main() {
@Hpmason
Hpmason / ChatGPT - leetcode problem: min_operations on palidrome
Created December 9, 2022 03:21
Example ChatGPT Generating leetcode problems
Problem:
You are given a string s consisting of lowercase English letters. You need to find the minimum number of operations required to make the string s a palindrome. In each operation, you can insert a character at any position in the string or delete a character from the string.
Function Signature:
```rust
fn min_operations(s: String) -> i32
```
Input: