原題有這樣的提示“Didyounoticethatthereversedintegermightoverflow?Assumetheinputisa32-bitinteger,thenthereverseof1000000003overflows.Howshouldyouhandlesuchcases?”看到有人寫了一個(gè)這樣的答案intreverse(intx){intflag=x>0?1:-1,res=0;x=x>0?x:-x;while(x>0){if((2147483647.0-x%10)/10
Leetcode Reverse Integer 中的溢出處理
達(dá)令說
2019-04-13 08:36:25