GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — leetcode/python/422_Valid_Word_Square.py at master · qiyuangong/leetcode Expand file tree/ Copy path422_Valid_Word_Square.pyMore file actions 23 lines (22 loc) · 805 Bytes / Copy path422_Valid_Word_Square.pyFile metadata and controls23 lines (22 loc) · 805 Bytes 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 class Solution(object): def validWordSquare(self, words): """ :type words: List[str] :rtype: bool """ if words is None or len(words) == 0: return True ls = len(words) for i in range(ls): for j in range(1, len(words[i])): if j >= ls: return False if i >= len(words[j]): return False if words[i][j] != words[j][i]: return False return True # def validWordSquare(self, words): # # https://discuss.leetcode.com/topic/63423/1-liner-python/2 # # The map(None, ...) transposes the "matrix", filling missing spots with None # return map(None, *words) == map(None, *map(None, *words)) |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |