This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |