r/PythonLearning • • 2d ago

Help Request Collections cheatsheet

Hi guys! Can you share your favorite cheatsheets for collections module? I'm trying to find one with asymptotics, but everything that I can find either doesn't contain them, or has limited set of functions and methods

5 Upvotes

4 comments sorted by

2

u/mc_pm 2d ago

The docs, right at the top, have a list of every container and what they do.

However, it's better to just know what is there so you can look it up later on rather than trying to memorize anything.

0

u/MidnightMappingMunch 2d ago

Thanks! I'm learning how to use python correctly for leetcode tasks. So I want to keep near myself the list of all supported operations, just to know what can I use for my algorithm, instead of scrolling through docs looking for an inspiration

2

u/mc_pm 2d ago

Well, I wouldn't actually suggest learning a language *for* leetcode tasks.

Data Structures & Algorithms are tools for solving different types of problems, and those problems exist regardless of the language. Also, leetcode is a terrible way to get better at programming.

But for those purposes you probably want to focus on something like deque (double ended queues will come up in various leetcode type questions), named tuples help keep your info organized, Counter is a convenient class. OrderedDict is sometimes useful.