My Blog List

[Leetcode Solution] Pow(x, n)

Analysis 

  • Using f[x]=f[x-1]*x could exceed the time limits because the range of x is the integer
  • Using f[x]=f[x/2]*f[x/2] would be fine.

Note

  • When x is negative, f(x)=1/f(-x). The only thing should be notice is that -INT_MIN==-INT_MIN. This case should be treated separately

Code


No comments:

Post a Comment

Enter you comment