Windows and Lists for Data Structures and Algorithmss
Windows and lists covers the sliding window technique, which maintains a moving range over an array or string to answer subarray questions in linear time, and linked lists, where nodes hold pointers to the next node. Common tasks include reversing a list, detecting cycles and finding the longest valid substring.
Stage: Linear Structures · Part of the Data Structures and Algorithms roadmap · Last reviewed 19 November 2026
What to learn in Windows and Lists
- Find the longest substring without repeating characters using a sliding window
- Shrink and expand a window while keeping a running count or sum
- Reverse a singly linked list iteratively by rewiring next pointers
- Detect a cycle with fast and slow pointers
- Merge two sorted linked lists using a dummy head node
Windows and Lists interview questions
How does Floyd's cycle detection work on a linked list?
Two pointers move through the list, one step and two steps at a time. If the list has a cycle, the faster pointer eventually catches the slower one inside it. If either reaches null, there is no cycle. It uses O(1) extra space.
When should you use a sliding window instead of brute force?
Use it when you need a contiguous subarray or substring satisfying a condition, and extending or shrinking the range updates the answer cheaply. It replaces re-scanning every start and end pair, cutting O(n squared) work to O(n).
Where Windows and Lists fits in the Data Structures and Algorithms roadmap
Windows and Lists belongs to the Linear Structures stage (intermediate level), which takes about 43 hours. Sequences.
Other units in this stage
Back to the full Data Structures and Algorithms roadmap