网页学习体会

  • 首页
  • 个人博客
您的位置: 首页  >  IT文章  >  【剑指offer】q34:丑数

【剑指offer】q34:丑数

分类: IT文章 • 2022-02-16 20:04:32

【剑指offer】q34:丑数

题目要求第n个丑数。所以对于中间结果不须要保存。

def Humble(index):
	curHum = 1
	M2 = 2; M3 = 3; M5 = 5
	while index > 1:
		curHum = min(min(M2, M3), M5)
		while M2 <= curHum:
			M2 *= 2
		while M3 <= curHum:
			M3 *= 3
		while M5 <= curHum:
			M5 *= 5
		index -= 1
	return curHum


相关推荐

  • 剑指Offer系列之题46~题50
  • 剑指Offer系列之题61~题67(完结)
  • 剑指Offer系列之题51~题55
  • 剑指offer-11-二进制中1的个数
  • 剑指offer-06-旋转数组的最小数字
  • 剑指offer-10-矩形覆盖
  • 剑指offer-05-用两个栈实现队列
  • 剑指offer-09-跳台阶
  • 剑指offer-字符串转为int数字,不用+来相加两个数,不用新增变量来交换数,在递增序列中找和为s的两个数字and找和为s的序列。 字符串转为int数字 不用+来相加两个数 PS.不用新增变量来交换数 在递增序列中找和为s的两个数字and找和为s的序列。
  • 剑指offer-在一维数组中找重复出现的数。
  • 第一个dubbo+zookeeper项目例子
  • 第一个登陆例子
    网站免责声明 网站地图 最新文章 用户隐私 版权申明
本站所有数据收集于网络,如果侵犯到您的权益,请联系网站进行下架处理。   

Copyright © 2018-2021   Powered By 网页学习体会    备案号:   粤ICP备20002247号