java solution

  • 0

    The logic is simple. post comments if you have any questions

    class Solution {
        public boolean validWordSquare(List<String> words) {
            for (int i = 0; i<words.size();i++){
            String answer="";
            String current = words.get(i);                                 
            for (String myString:words){
                int length = myString.length();
                if (i>=length){continue;}
                 answer = answer+ Character.toString(myString.charAt(i));                        
            if (!(current.equals(answer)))return false;
            return true;

Log in to reply

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