2、LeetCode 478. 在圆内随机生成点
(1)题目
给定圆的半径和圆心的位置,实现函数 randPoint ,在圆中产生均匀随机点。
实现 Solution 类:
Solution(double radius, double x_center, double y_center) 用圆的半径 radius 和圆心的位置 (x_center, y_center) 初始化对象 randPoint() 返回圆内的一个随机点。圆周上的一点被认为在圆内。答案作为数组返回 [x, y] 。
示例 1:
输入: [“Solution”,“randPoint”,“randPoint”,“randPoint”] [[1.0, 0.0, 0.0], [], [], []] 输出: [null, [-0.02493, -0.38077], [0.82314, 0.38945], [0.36572, 0.17248]] 解释: Solution solution = new Solution(1.0, 0.0, 0.0); solution.randPoint ();//返回[-0.02493,-0.38077] solution.randPoint ();//返回[0.82314,0.38945] solution.randPoint ();//返回[0.36572,0.17248]
提示:
0 < radius
关注
打赏
热门博文
- 【文献汇总】2019-2021最新应用深度学习到OFDM通信系统中的论文汇总(实时更新)
- 【金融量化】电话口试-智力题
- 【数据挖掘】2022年2023届秋招爱玩特智能量化研究员岗 笔试题
- 【Leetcode刷题Python】1467. 两个盒子中球的颜色数相同的概率
- 【Leetcode刷题Python】50. Pow(x, n)
- 【Leetcode刷题Python】牛客. 数组中未出现的最小正整数
- 【Leetcode刷题Python】73. 矩阵置零
- 【Leetcode刷题Python】LeetCode 478. 在圆内随机生成点
- 【Leetcode刷题Python】 LeetCode 2038. 如果相邻两个颜色均相同则删除当前颜色
- 【数据挖掘】2022年2023届秋招Kanaries雾角科技算法岗 笔试题