Language/Go
[Golang으로 도전하는 Leetcode] Implement Rand10() Using Rand7()Solution
오늘은 Implement Rand10() Using Rand7()Solution를 풀어보도록 하겠습니다 링크는 https://leetcode.com/problems/implement-rand10-using-rand7 입니다 맨 처음에는 어떤식으로 접근해야할지 몰랐습니다 rand7에서 하나 뽑고 1,2,3에서 랜덤으로 뽑아서 더하면 되는거 아닌가? 라는 식으로 접근을 하였습니다 func rand10() int { return rand7() + rand7()%3 } 이렇게 쉽게 통과 될리가 없죠 ㅠㅠ 그 뒤로 블로그 글들을 찾으면서 어떤 알고리즘으로 접근해야 하는지 고민을 해보았습니다 https://all2one.tistory.com/entry/rand5%EB%A1%9C-rand7-%EA%B5%AC%ED%9..
2020. 8. 30. 17:30