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.
Very neat, good to include the range(max(a), min(b)+1) to bound the search for x's, and exclude candidates from both sides with a single parent loop. An idea for optimisation...
max(a) is odd, min(b) is odd, just search odds
max(a) is odd, min(b) is even, search all
max(a) is even, min(b) is even, just search evens
max(a) is even, min(b) is odd, don't search anything
I wonder if there are others.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Between Two Sets
You are viewing a single comment's thread. Return to all comments →
Very neat, good to include the range(max(a), min(b)+1) to bound the search for x's, and exclude candidates from both sides with a single parent loop. An idea for optimisation...
max(a) is odd, min(b) is odd, just search odds
max(a) is odd, min(b) is even, search all
max(a) is even, min(b) is even, just search evens
max(a) is even, min(b) is odd, don't search anything
I wonder if there are others.