LeedCode
Problems
Math & Geometry
21 remaining tasks
1071 - Greatest Common Divisor of Strings
Easy
1523 - Count Odd Numbers in an Interval Range
Easy
1572 - Matrix Diagonal Sum
Easy
0149 - Maximum Points on a Line
Easy
0048 - Rotate Image
Easy
0054 - Spiral Matrix
Easy
0059 - Spiral Matrix II
Easy
0073 - Set Matrix Zeroes
Easy
0202 - Happy Number
Easy
0066 - Plus One
Easy
0009 - Palindrome Number
Easy
0263 - Ugly Number
Easy
1260 - Shift 2D Grid
Easy
0013 - Roman to Integer
Easy
0012 - Integer to Roman
Easy
0050 - Pow(x, n)
Easy
0043 - Multiply Strings
Easy
2013 - Detect Squares
Easy
1041 - Robot Bounded In Circle
Easy
0006 - Zigzag Conversion
Easy
2028 - Find Missing Observations
Easy
0263 - Ugly Number
Easy
Javascript
Code
var isUgly = function(n) {
    if(n <= 0)
        return false;
    
    for(const p of [2, 3, 5])
        while(n % p == 0)
            n = n / p;
    return n == 1;
};
Mark as complete
Close
Shortcut: Ctrl + .
Shortcut: Ctrl + /