Speed Test
Python list.insert(0) vs deque: Why Adding to the Front of a List Is Slow
· Python list.insert(0) vs deque | deque hazaar guna se zyada fast
Adding to the front of a Python list shifts every other item, so list.insert(0) is O(n) per insert. collections.deque adds to either end in O(1). On my Mac, 100,000 front inserts took about 2.5 s with a list and about 2 ms with deque.
Interview SheetPractise the patterns behind interview problemsProblems grouped by pattern, each with the idea first and the code in four languages.


![Animated sliding window over the array [2, 1, 5, 1, 3, 2]: a three-number window adds the new number and subtracts the old one, showing sums 8, 7, 9 and 6 and a maximum of 9.](https://i.ytimg.com/vi/NM5paB6_7wg/maxresdefault.jpg)