Back to course home
0% completed
Vote For New Content
What is the difference between these two ranges of for loops:for i in range(len(...
Daniel Lim
Apr 17, 2022
What is the difference between these two ranges of for loops:
for i in range(len(arr)-K+1)
and
for i in range(K)
1
0
Comments
Comments
A
Andrei 2 years ago
I was wondering the same thing at first, however after a bit of time I realised that it so happens that in the example: K=5, arr.size()=9, we get 5 for arr.size() - K + 1, since: 9 - 5 + 1 = 5.
arr.size() - K + 1 is required to determine how many subarrays there are w...
On this page