This is a very old video, for better sound and camera quality DSA videos, learn from the below playlist! Java Plus DSA ( Java + DSA + Problem Solving ) th-cam.com/play/PLQ7ZAf76c0ZPVdhV1bAjFv0bQc1xHURzE.html
No. See consider it as starting and ending point., we need to consider all elements and shift them to a window of size exactly m. Let's say m=3. Elements are 1 2 3 4 5 So first window would be 1 2 3 2nd would be 2 3 4 3rd would be 3 4 5 Now can we take 4 5 ?? No we can't because window size is 3 and we are left with only 2 elements. So what was the starting element of last valid window, it is 3. Let's check indexes now. Element 1 2 3 4 5 Index. 0 1 2 3 4 Index of 3 is 2. So valid Iteration is from i=0 to i=2. That is why this equation will work i+m-1
We have window of M elements, We add the first and last element of the window, and check if it is less than any of the previous window. Then repeat this process. Math.min( A , B ) ; means return minimum value. B means previous ans. A means a.get( i + m - 1 ) + a.get( i ) a.get (i + m - 1) means last element of window. a.get (i) means first element of window.
Please find below video with better sound quality ❤
th-cam.com/video/oYNU1TD9W5Y/w-d-xo.htmlsi=MLzZEX3MghRNe0LY
This is a very old video, for better sound and camera quality DSA videos, learn from the below playlist!
Java Plus DSA ( Java + DSA + Problem Solving )
th-cam.com/play/PLQ7ZAf76c0ZPVdhV1bAjFv0bQc1xHURzE.html
how is i+m-1
No.
See consider it as starting and ending point., we need to consider all elements and shift them to a window of size exactly m.
Let's say m=3.
Elements are
1 2 3 4 5
So first window would be
1 2 3
2nd would be
2 3 4
3rd would be
3 4 5
Now can we take
4 5 ??
No we can't because window size is 3 and we are left with only 2 elements.
So what was the starting element of last valid window, it is 3.
Let's check indexes now.
Element 1 2 3 4 5
Index. 0 1 2 3 4
Index of 3 is 2.
So valid Iteration is from i=0 to i=2.
That is why this equation will work i+m-1
I am not able to understand from i+m
Sorry for that typo, It will be i+m-1
you explained very nicely👍
thank you bhaiya itni achhi tarah samjhane k liye
No problem. Java Plus dsa course chal rha hai, pls share with your juniors. 😃
Thank you for the explanation
i
lovely
thanks
आप Lbsnaa गए हो????
can u publish the swift code for the same
can we do this O(n) time
Can Anyone please Explain:
Math.min(a.get(i+(int)m-1)+a.get(i), minDiff);
We have window of M elements,
We add the first and last element of the window, and check if it is less than any of the previous window. Then repeat this process.
Math.min( A , B ) ; means return minimum value.
B means previous ans.
A means a.get( i + m - 1 ) + a.get( i )
a.get (i + m - 1) means last element of window.
a.get (i) means first element of window.
Isn't this a brute force solution ?
Accenture 2023 aptitude coding question
I don't want chocolate
😂😂