We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Changing lists to sets worked. Yeah, when I was choosing which type to use I kinda wanted something like SortedSet(http://www.grantjenks.com/docs/sortedcontainers/index.html), but when I didn't find it in the stock library I felt that sorting was more important and set has no order so I used lists with sorting. Now that I think about it after looking at your calculations, I feel silly for thinking that. If a list is used the size of states or len(states) actually reaches 2**N or 1e30 in worst case - if N is set to 100 and G is sufficiently large(>sum(A)). And if you remove duplicates e.g. by using a set, then the size is limited by what's it members can be - from 0 to A*N or 100*100=10 000 in worst case,i.e. no more than 10 001 members...
So yeah, thanks for the advice m8.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
The Indian Job
You are viewing a single comment's thread. Return to all comments →
Changing lists to sets worked. Yeah, when I was choosing which type to use I kinda wanted something like SortedSet(http://www.grantjenks.com/docs/sortedcontainers/index.html), but when I didn't find it in the stock library I felt that sorting was more important and set has no order so I used lists with sorting. Now that I think about it after looking at your calculations, I feel silly for thinking that. If a list is used the size of states or len(states) actually reaches 2**N or 1e30 in worst case - if N is set to 100 and G is sufficiently large(>sum(A)). And if you remove duplicates e.g. by using a set, then the size is limited by what's it members can be - from 0 to A*N or 100*100=10 000 in worst case,i.e. no more than 10 001 members... So yeah, thanks for the advice m8.