aboutsummaryrefslogtreecommitdiff
path: root/other/check_pangram_sentence.rs
diff options
context:
space:
mode:
authorJack Sangdahl <[email protected]>2025-03-10 00:36:13 -0600
committerJack Sangdahl <[email protected]>2025-03-10 00:36:13 -0600
commit7c60dee83b436e8e8a667bf9f191beced8de4fc3 (patch)
treeeb7a24ee2067f92245c57bb118e85a1baf15df50 /other/check_pangram_sentence.rs
parent5d7cdc215e4ba1ec4cbb24c084cccb5e5e641468 (diff)
downloadleetcode-7c60dee83b436e8e8a667bf9f191beced8de4fc3.tar.gz
leetcode-7c60dee83b436e8e8a667bf9f191beced8de4fc3.zip
chore: move cpp and rust code to directory
Diffstat (limited to 'other/check_pangram_sentence.rs')
-rw-r--r--other/check_pangram_sentence.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/other/check_pangram_sentence.rs b/other/check_pangram_sentence.rs
new file mode 100644
index 0000000..0f69c31
--- /dev/null
+++ b/other/check_pangram_sentence.rs
@@ -0,0 +1,21 @@
+struct Solution;
+
+impl Solution {
+ pub fn check_if_pangram(sentence: String) -> bool {
+ let mut bit_mask: u32 = 0;
+ let mut count = 0;
+ for c in sentence.chars() {
+ let idx = c as usize - 'a' as usize;
+ if bit_mask & (1 << idx) == 0 {
+ count += 1;
+ }
+ bit_mask |= 1 << idx;
+ }
+ count == 26
+ }
+}
+
+fn main() {
+ let sentence = String::from("thequickbrownfoxjumpsoverthelazydog");
+ print!("{}", Solution::check_if_pangram(sentence));
+}