109. implement `Math.pow()`

Is this helpful ?

from all members: - accepted / - tried

Can you write your own Math.pow() ? The power would only be integers.

pow(1, 2)
// 1

pow(2, 10)
// 1024

pow(4, -1)
// 0.25

All inputs are safe.


You can easily solve this problem by multiplying the base one after another, but it is slow. For power of n, it is needed to do the multiplication n times, can you think of a faster solution ?

Let's try to solve this problem within 10 mintues.