18
Last seen 9 months ago
Member for 9 years, 6 months, 9 days
Difficulty Normal
Will be more readable if you use slices for this solution.
More
Good solution, but I think you may improve this.
Firstly, you check list is non-empty if empty you will return True.
Secondly, you check if non-empty length list equal 1.
Probably, will be good something like this:
return len(set(elements)) < 2
More
nice solution.
It will be nice to use `string.ascii_uppercase` instead `ABCD...`. It will be more robust code.
More
I think this solution should be in uncategorized solutions.
Firstly, you may use
from collections import defaultdict
that create dict with all data count
And secondly, you approach looks like
O(n*log(n))
but in general in this category for this issue -
O(n)
More
Good, but you used many variables. You could just use the function without assigning
More
Good solution, but I think better to solve like this:
def checkio(arr):
return sum(arr[::2]) * arr[-1] if arr else 0
This decision is shorter and slightly more understandable :)
More
Sorry, but I don't understand about this code:
l=len(w) if len(w)>=3 else 0
Can you tell me please - why is this necessary here?
It's look like overhead.
Thanks
More
Solution isn't bad, but did you hear about `set` ?
Your solution not effective with big data string. Try resolve it with `set`.
Thanks
More
You can use new style f-string like f'My name is {name} and I'm {age}' instead of format.
More
Looks good for clear solution, but non-effective around big-O.
Looks like O(n**2) for this solution.
More
if line == '':
You may use for true statement:
if line:
and for false statement:
if not line:
So if all summarize, you may start you solution, e.g.
if line:
some code when you some number
return something > 0
return 0
More
if len(line) == 0:
max_count = 0
elif len(line) == 1:
max_count = 1
Maybe, it will be better if you change to:
if len(line) in [0, 1]:
return len(line)
or you may write something like this:
if len(line) in range(2):
return len(line)
More
I think it will be better if you use in condition:
if not line:
return 0
or will be the best
if line:
some code which return > 0
return > 0
return 0
More
For more readable you might write something like this:
flag = True
if elements:
some your code
return flag
More
You may use in this case smth like this:
return max(args) - min(args) if args else 0
More
1. You may use builtin functions: **max()** and **min()**
2. Sometimes if you use only one **if** without else it will look more readeable
if args:
TODO something
return your_code
return 0
3. List comprehension is a very good tool. But in this case I think it doesn't ne
More