Add data structure example i.e. Nested list, Counter, Lambda function, Sorting, deque, heap.
While solving any kind of problem, the data structure is important. I want to contribute to this repository by adding examples on the above topics with proper documentation.
Basically, each of the topics will contain motivation, use case, example, dos, and don't-s.
Here's an example:
Initializing a nested list in this format [ [ v ] * n ] * n is not always a good idea.
Thanks. But it doesn't make sense to add this code to the course samples because it wasn't covered in the course. The code you see is meant to be as exactly the same as on screen.
Add data structure example i.e. Nested list, Counter, Lambda function, Sorting, deque, heap.
While solving any kind of problem, the data structure is important. I want to contribute to this repository by adding examples on the above topics with proper documentation.
Basically, each of the topics will contain motivation, use case, example, dos, and don't-s.
Here's an example:
Initializing a nested list in this format
[ [ v ] * n ] * n
is not always a good idea.Look at the snippet below:
So all of the 0th element of the lists got changed. It's because
*
is copying the address of the object (list).Like this