• + 0 comments

    Java 15

    public static String canConstruct(List<Integer> a) {
            int res = 0;
    
            for (Integer i : a) {
                char[] charArray = String.valueOf(i).toCharArray();
                for (char c : charArray) {
                    res += Integer.parseInt(Character.toString(c));
                }
            }
            return (res % 3 == 0)? "Yes" : "No";
        }