MCPcopy Create free account
hub / github.com/StudyRust/leetcode_rust / is_good

Function is_good

788-rotated-digits.rs:2–16  ·  view source on GitHub ↗
(e: i32)

Source from the content-addressed store, hash-verified

1pub fn rotated_digits(n: i32) -> i32 {
2 pub fn is_good(e: i32) -> bool {
3 let digit_chars = e.to_string().chars().collect::<Vec<char>>();
4 let mut count = 0;
5 for digit_char in digit_chars {
6 if digit_char == '3' || digit_char == '4'
7 || digit_char == '7' {
8 return false
9 }
10 if digit_char == '2' || digit_char == '5'
11 || digit_char == '6' || digit_char == '9' {
12 count += 1
13 }
14 }
15 count > 0
16 }
17 let mut nums = (1..=n).collect::<Vec<i32>>();
18 nums.retain(|e|is_good(*e));
19 nums.len() as i32

Callers 1

rotated_digitsFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected