rustgym/leetcode/_441_arranging_coins.rs
1struct Solution;
2
3impl Solution {
4 fn arrange_coins(n: i32) -> i32 {
5 (((2 * n as i64) as f64 + 0.25).sqrt() - 0.5).floor() as i32
6 }
7}
8
9#[test]
10fn test() {
11 assert_eq!(Solution::arrange_coins(5), 2);
12 assert_eq!(Solution::arrange_coins(8), 3);
13 assert_eq!(Solution::arrange_coins(1_804_289_383), 60070);
14}