422. Valid Word Square

Solution:

思路:

Time Complexity: O(N) Space Complexity: O(N)

Solution Code:

public class Solution {
    public boolean validWordSquare(List words) {
        if(words == null || words.size() == 0){
            return true;
        }
        int n = words.size();
        for(int i=0; i= n || words.get(j).length() <= i || words.get(j).charAt(i) != words.get(i).charAt(j))
                    return false;
            }
        }
        return true;
    }
}

你可能感兴趣的:(422. Valid Word Square)