算法:LeetCode470_用Rand7()实现Rand10()_java实现

java 复制代码
/**
 * LeetCode470_用Rand7()实现Rand10()
 */
public class LeetCode470 extends SolBase {
	public int rand10() {
		int temp = 40;
		while (temp >= 40) {
			temp = (rand7() - 1) * 7 + rand7() - 1;
		}
		return temp % 10 + 1;
	}
}

解题思路分析过程:

相关推荐
wuxianda103033 分钟前
Swift 项目用 Xcode 脚手架起步:默认工程结构和依赖组合为什么会被识别成同源
开发语言·xcode·swift·4.3a·appstore审核
nice_lcj52035 分钟前
【从零理解计算机网络 · 04】TCP 三次握手:为什么恰好是三次
java·后端·tcp/ip·计算机网络·面试·tcp·三次握手
ShineWinsu1 小时前
对于Qt:QVBoxLayout常见属性以及方法的解析
开发语言·数据库·c++·qt·gui·客户端·布局管理器
Sarvartha1 小时前
反射综合案例:SQL 语句生成
java·开发语言
Resean022311 小时前
Spring 源码分析(二)配置类的解析与扫描
java·后端·spring
小毛球.11 小时前
第 3 篇:IDEA 最新版下载与完整安装教程(Mac)
java·macos·intellij-idea·idea
ShineWinsu12 小时前
对于Qt:QFormLayout常见属性以及方法的解析
开发语言·c++·qt·面试·客户端·表单·qformlayout
Misnearch13 小时前
ScheduledExecutorService
java·线程池
ashiho14 小时前
【LeetCode hot 100】3. 无重复字符的最长子串 (三种解法)
java·数据结构·后端·算法·leetcode·滑动窗口
T_Wizard14 小时前
AI 回复为什么要转圈 3 秒才「啪」一下全出来?把流式输出拆开看,顺便踩了 6 个坑
java·ai编程