Constructing a Number

  • + 0 comments

    static String canConstruct(int[] a) { // Return "Yes" or "No" denoting whether you can construct the required number. int len=a.length; int sum=0; for(int a1:a){ for(;a1>0;a1=a1/10) sum=sum+a1%10; } if(sum%3==0) return "Yes"; else return "No"; }