Code-1-js
2017-02-06 本文已影响0人
游荡的猫咪
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:
note:Math.abs, Math.pow;ps: 此方法用字符串处理,有点怪怪的~~但速度较快~~
- method 2 :
note:直接数据运算,但运行速度不够快~~