Reverse the decimal digits of a signed 32-bit integer x; return 0 if the reversed value falls outside [-2^31, 2^31 - 1]. Two approaches — switch and watch how each handles digits, sign and overflow.
0
[-2^31, 2^31 - 1]