arranging-coins
This commit is contained in:
parent
1d06af2727
commit
98f8727286
|
@ -0,0 +1,9 @@
|
|||
package main
|
||||
|
||||
import "math"
|
||||
|
||||
// Time: O(1) (assuming computer has float64 sqrt instruction)
|
||||
// Space: O(1)
|
||||
func arrangeCoins(n int) int {
|
||||
return int(math.Sqrt(float64(2*n)+0.25) - 0.5)
|
||||
}
|
Loading…
Reference in New Issue