[LeetCode][JavaScript]7. Reverse Integer

Athem
2 min readDec 21, 2019

--

喔耶~這題好簡單~速戰速解!

程度:EASY

題目傳送門:https://leetcode.com/problems/reverse-integer/

題目

Given a 32-bit signed integer, reverse digits of an integer.

Example 1:

Input: 123
Output: 321

Example 2:

Input: -123
Output: -321

Example 3:

Input: 120
Output: 21

Note:
Assume we are dealing with an environment which could only store integers within the 32-bit signed integer range: [−231, 231 − 1]. For the purpose of this problem, assume that your function returns 0 when the reversed integer overflows.

題目解釋

把數字反轉、反轉後正負號也得保留、有最大最小值限制,一旦超過則為0。也不用思考方式了~超級白話XD直接解題!

解題筆記

心得

連提示都不用看自己就寫出來了~希望我解Medium也覺得簡單的那天快來!其實每次這樣寫心得,回去看筆記的時候都感覺到當時的心情,也勉勵自己要越來越厲害,所以我要繼續堅持下去!

--

--