my answer


  • 0
    Z

    class Solution {
    public List<Integer> selfDividingNumbers(int left, int right) {
    List<Integer> list=new ArrayList<>();
    for(int i=left;i<=right;i++){
    String s=""+i;
    if(s.contains("0")) continue;
    if(IsOK(i)){
    list.add(i);
    }
    }
    return list;
    }
    public boolean IsOK(int n){
    String s=""+n;
    int leng=s.length();
    for(int i=0;i<leng;i++){
    if(n%Integer.valueOf(""+s.charAt(i))!=0){
    return false;
    }
    }
    return true;
    }
    }


Log in to reply
 

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