aboutsummaryrefslogtreecommitdiff
path: root/check_pangram_sentence.rs
diff options
context:
space:
mode:
authorjack <[email protected]>2024-06-14 13:13:15 -0600
committerjack <[email protected]>2024-06-14 13:13:15 -0600
commitd343a3b18dbaca9297d4f7b2280c4a16f0a5c8aa (patch)
tree96df922dae2a5073d9a50ea70c7aae6aa37e3ebe /check_pangram_sentence.rs
downloadleetcode-d343a3b18dbaca9297d4f7b2280c4a16f0a5c8aa.tar.gz
leetcode-d343a3b18dbaca9297d4f7b2280c4a16f0a5c8aa.zip
initial
Diffstat (limited to 'check_pangram_sentence.rs')
-rw-r--r--check_pangram_sentence.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/check_pangram_sentence.rs b/check_pangram_sentence.rs
new file mode 100644
index 0000000..0f69c31
--- /dev/null
+++ b/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));
+}