leetcode刷题39
今天刷的题是LeetCode第7题,反转整数
class Solution { public int reverse(int x) { Long y=0L; int returnNum=0; while (x!=0){ int num=x%10; y=y*10+num; x=x/10; } if(y>(Math.pow(2,31)-1)||y<-Math.pow(2,31)){ returnNum=0; }else { returnNum= Math.toIntExact(y); } return returnNum; } }