Implement Rand10() Using Rand7() LeetCode solution in Python

1
class Solution:
2
def rand10(self):
3
"""
4
:rtype: int
5
"""
6
x = rand7()
7
y = rand7()
8
pos = (x - 1) * 7 + y
9
if pos > 40:
10
return self.rand10()
11
return (pos % 10) + 1

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0