neetcode-gh / leetcode

Leetcode solutions
MIT License
5.44k stars 2.26k forks source link

0079-word-search #3130

Open giggling-ginger opened 9 months ago

giggling-ginger commented 9 months ago
count = defaultdict(int, sum(map(Counter, board), Counter()))
if count[word[0]] > count[word[-1]]:
    word = word[::-1]

could be improved to:

count = sum(map(Counter, board), Counter())
if count[word[0]] > count[word[-1]]:
    word = word[::-1]

still works and the syntax is shorter.

itsmohitnarayan commented 7 months ago

can i do?? can i open the pull request of solution provided by you?

giggling-ginger commented 7 months ago

can i do?? can i open the pull request of solution provided by you?

Yes of course! Go ahead