Leetcode Go Calculate Money in Leetcode Bank
Calculate Money in Leetcode Bank - LeetCode
https://leetcode.com/problems/calculate-money-in-leetcode-bank/
- Go 言語で取り組んだメモ
回答
O(1) Time Math solution - Calculate Money in Leetcode Bank - LeetCode
https://leetcode.com/problems/calculate-money-in-leetcode-bank/solutions/2501610/o-1-time-math-solution/
func totalMoney(n int) int {
w := n/7
d := n%7
res:=7*((w-1)*w)/2+28*w+(d+d*d)/2+w*d
return res
}