🟧 Medium
My Solution
func myPow(x float64, n int) float64 { minus := n < 0 if minus{ n = -n } var a float64 = 1 for n !=0 { if n & 1 != 0{ a *= x } x *= x n = n >> 1 } if minus { a = 1/a } return a }
Last updated 4 months ago
Was this helpful?
Leetcode: