Ad

If x have number 3 return true or false

Code
Diff
  • fn solution(mut x: i32) -> bool {
        x = x.abs();
        while x > 0 {
            if x % 10 == 3 {
                return true;
            }
            x /= 10;
        }
        false
    }
    • fn solution(x: i32) -> bool {
    • x.to_string().chars().any(|x| x == '3')
    • fn solution(mut x: i32) -> bool {
    • x = x.abs();
    • while x > 0 {
    • if x % 10 == 3 {
    • return true;
    • }
    • x /= 10;
    • }
    • false
    • }