You are viewing a single comment's thread. Return to all comments →
You could use a generator expression instead of a list comprehension.
def getWays(squares, d, m): return sum(1 for i in range(n-m+1) if sum(s[i:i+m])==d)
But if you want a more efficient solution for larger inputs, use a sliding window (see the following link). https://www.hackerrank.com/challenges/the-birthday-bar/submissions/code/43358272
Seems like cookies are disabled on this browser, please enable them to open this website
Subarray Division
You are viewing a single comment's thread. Return to all comments →
You could use a generator expression instead of a list comprehension.
But if you want a more efficient solution for larger inputs, use a sliding window (see the following link). https://www.hackerrank.com/challenges/the-birthday-bar/submissions/code/43358272