Code-1-js

Question 1:

Reverse digits of an integer.Example1:x = 123, return 321 Example2:x = -123, return -321

Note:

The input is assumed to be a 32-bit signed integer. Your function should return 0 when the reversed integer overflows.


Answer:

 - method 1:

Code-1-js_第1张图片

note:Math.abs, Math.pow;ps: 此方法用字符串处理,有点怪怪的~~但速度较快~~


- method 2 :

Code-1-js_第2张图片

note:直接数据运算,但运行速度不够快~~

你可能感兴趣的:(Code-1-js)