Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
579 B
2
Indexable
Never
class Solution {
    public int countSymmetricIntegers(int low, int high) {
        int c=0;
        for(int i=low;i<=high;i++){
            String s=""+i;
            if(s.length()%2==0){
                int l=0;
                int r=0;
                for(int j=0;j<s.length()/2;j++){
                    r+=s.charAt(j)-'0';
                }
                for(int j=s.length()/2;j<s.length();j++){
                    l+=s.charAt(j)-'0';

                }
                if(l==r)
                c++;
            }
        }
        return c;
    }
}