Skip to content

Tag: hashmap

How allocation of memory for `dict` in Python works?

I was playing around with Dictionaries and found this. Output: The size of Dictionary length 7 and 10 is the same that is 196 but for length 11, it’s 344. Why are they same? Why does the size rise up with length 11? How does dictionary size work in Python? Answer When you create an empty dictionary, it …

Find the length of largest subarray with 0 sum

Given an array of integers, find the length of the longest sub-array with sum equals to 0. Here is an approach to this problem The Efficient approach But fails for test cases like , Do you have another approach to this problem ? Answer To spell out the solution from the comment. First create a generator to yi…