Implement Rand10() Using Rand7() LeetCode solution in C++

1
class Solution {
2
public:
3
int rand10() {
4
while (true) {
5
int col = rand7();
6
int last_row_tak = (rand7() - 1) * 7;
7
int val = last_row_tak + col;
8
if (val <= 40) {
9
return (val - 1) % 10 + 1;
10
}
11
}
12
}
13
};

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0