14
Тимур Кушуков
Last seen 2 years ago
Member for 5 years, 4 months, 26 days
Difficulty Normal
```python
indices = set(range(len(matrix)))
...
while {i, j} <= indices
```
That's a cool trick.
Not as efficient as
```python
n = len(matrix)
...
while 0<=iMore
Nice and short :) But it has O(N*M) complexity because for each word in words it scans elements with index function.
It can be improved to O(N+M) using 2 pointers technique
More
You can simplify to
return bool(re.search(r'[A-Za-z]+\s[A-Za-z]+\s[A-Za-z]+',words))
More
You can use "ascii_lowercase", "ascii_uppercase" and "digits" variables from "string" module. Less typing ;)
More
Nice solution, here some posible improvements. You can use:
1) operaror.itemgetter instead of lambda. It is faster and more readable.
2) reverse=True as sorted parameter ;)
More
"if key in counter.keys() else 0" part is unnecessary. Counter of unknown key equals zero by default.
More