Skip to content

Jeffma0103/Reverse-Integer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

Reverse-Integer (medium)

Solution of Reverse Integer

將 32 bit 的整數翻轉, 如果結果超出 [-2^31, 2^31 - 1] 的範圍, 則 return 0

ex1:

Input:
x = 123

Output:
321

ex2:

Input:
x = -123

Output:
-321

ex3:

Input:
x = 120

Output:
21

Workaround   1

想法

  • 寫一個 check function 判斷結果值是否在範圍內
  • 判斷 x 是否等於 0
  • 判斷 x 為正負值
  • 翻轉後的結果再由 check function 進行判斷

About

Solution of Reverse Integer

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages