Constructing a Number

  • + 0 comments

    My solution for this code is.

    public static String canConstruct(List<Integer> a) {
        // Return "Yes" or "No" denoting whether you can construct the required number.
           int sum=0;
            int[] arr=a.stream().mapToInt(Integer::intValue).toArray();
    
            for(int l:arr){
                sum+=l;
            }
            if(sum%3==0)
                return "Yes";
            }
    
       return "No";
             }