You are viewing a single comment's thread. Return to all comments →
In Python 3, str is unicode strings. They take more space than byte strings. This may be one of the reasons for getting Runtime Error.
Runtime Error
Code Python 2
>>> import sys >>> print(sum([sys.getsizeof(i) for i in '12345689'*10**5])) 17600000
Code Python 3
>>> import sys >>> print(sum([sys.getsizeof(i) for i in '12345689'*10**5])) 20800000
To overcome this, we can simply avoid creating a huge list, which is causing memory error.
I have added a solution in Python 3 in Editorial.
*One can also, try solving this using Counters.
Counters
Seems like cookies are disabled on this browser, please enable them to open this website
The Captain's Room
You are viewing a single comment's thread. Return to all comments →
In Python 3, str is unicode strings. They take more space than byte strings. This may be one of the reasons for getting
Runtime Error
.Code Python 2
Code Python 3
To overcome this, we can simply avoid creating a huge list, which is causing memory error.
I have added a solution in Python 3 in Editorial.
*One can also, try solving this using
Counters
.