Grokking the Coding Interview: Patterns for Coding Questions
Ask Author
Back to course home

0% completed

Vote For New Content
Tu Huy Nguyen
Should "window_end >= k - 1" be "window_end - window_start > k - 1" better?

Tu Huy Nguyen

Jan 21, 2025

In sliding window solution, shouldn't if window_end >= k - 1: be if window_end - window_start > k - 1: for better? window_end - window_start represents the size of the windows.

0

0

Comments
Comments
Tu Huy Nguyen
Tu Huy Nguyen9 months ago

Oh I get it now. If use window_end - window_start, the code will be a bit longer (but easier for newbie to understand).

On this page