Your browser does not seem to support JavaScript. As a result, your viewing experience will be diminished, and you have been placed in read-only mode.

Please download a browser that supports JavaScript, or enable it if it's disabled (i.e. NoScript).

double pow(double x, int n) { if (x == 0) return 0; if (n == 0) return 1; if (n < 0) n = -n, x = 1/x; return n % 2 ? x*pow(x*x, n/2) : pow(x*x, n/2); }

Yes, it can be. If you can come up with a O(1) memory solution (is there is one). You are using O(lg(n)) system stack. May be it will be a couple of more lines in your code, but better complexity beats smaller code any day. Just encouraging...

He said concise not efficient

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.