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.
so first in for loop range(n), it gets all the index of a and b, which is [1,2,4], [3,5]
then in for loop range(m) it checks: where is a's index ? where is b's index
if a's index or b's index == None, that means d[input()] in for loop range(m) == [] right?(it's None). So in this python doc:https://docs.python.org/3/library/stdtypes.html#truth-value-testing
it shows that: "empty sequences and collections: '', (), [], {}, set(), range(0)"
are considered False. So if it False, with False and -1, it's a boolean operator, simple, right ? It prints -1. Hope u can understand
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
DefaultDict Tutorial
You are viewing a single comment's thread. Return to all comments →
so first in for loop range(n), it gets all the index of a and b, which is [1,2,4], [3,5] then in for loop range(m) it checks: where is a's index ? where is b's index if a's index or b's index == None, that means d[input()] in for loop range(m) == [] right?(it's None). So in this python doc:https://docs.python.org/3/library/stdtypes.html#truth-value-testing it shows that: "empty sequences and collections: '', (), [], {}, set(), range(0)" are considered False. So if it False, with False and -1, it's a boolean operator, simple, right ? It prints -1. Hope u can understand