Input: 1534236469 & Expected: 0?


  • 0
    S

    I found two problems seems weird:

    • list item when i put my code into test, there will be a result as "wrong answer" which shows "Input: 1534236469 Output: 1056389759 Expected: 0"
    • list item my code on eclipse seems working well (may not tested well)
    public class Solution {
        public int reverse(int x) {
            int r=0;
            ArrayList<Integer> list=new ArrayList<Integer>();
    	while(x!=0){
    		list.add(x%10);
    		x/=10;
    	}
    	int i=(int)Math.pow(10,list.size()-1);
    	for(int n:list){
    		r+=n*i;
    		i/=10;
    	}
        	return (r);
        }
    }
    

  • 0
    U

    Same question here!


  • 0
    S

    @user1012186 I'm going to solve this with C later :D


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.