博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
leetcode Ugly Number
阅读量:2341 次
发布时间:2019-05-10

本文共 633 字,大约阅读时间需要 2 分钟。

思路:

题目不难。。但是陷阱很多。比如1和0

public class Solution {
public boolean isUgly(int num) { if(num==0) { return false; } if(num==1) { return true; } while(true) { if(num%2==0) { num/=2; } else if(num%3==0) { num/=3; } else if(num%5==0) { num/=5; } else { return false; } if(num==1) { return true; } } }}

转载地址:http://zduvb.baihongyu.com/

你可能感兴趣的文章
图解LeetCode No.18之四数之和
查看>>
402. Remove K Digits
查看>>
75. Sort Colors
查看>>
获取数组中前K小的数字
查看>>
数组heapify变为堆结构
查看>>
二叉树的非递归遍历
查看>>
218. The Skyline Problem
查看>>
Java PAT (Basic Level) Practice 写出这个数
查看>>
Python PAT (Basic Level) Practice 1016 部分A+B
查看>>
Python PAT (Basic Level) Practice 1006 换个格式输出整数
查看>>
Python PAT (Basic Level) Practice 1009 说反话
查看>>
Python PAT (Basic Level) Practice 1011 A+B 和 C
查看>>
Python PAT (Basic Level) Practice 1017 A除以B
查看>>
Python PAT (Basic Level) Practice 1042 字符统计
查看>>
spring dubbo 2.7.3 zookeeper 项目构建
查看>>
spring dubbo 报错
查看>>
如何在非 bean 对象中注入 dubbo service
查看>>
前后端分离 ajax java跨域配置 spring boot 、 spring security
查看>>
java spring boot 拦截所有请求 显示请求路径 方法 ip 等
查看>>
java spring boot jackson 配置 null字符串为"" null数组为[]
查看>>