I have a O(nlogn) solution. (The algorithm is O(n) but requires a sort first, which I believe is O(nlogn).)
But I believe I'm getting TLE because my input is slow, or at least I want to eliminate this possibility.
What's the fastest way to input this data? I'm currently using:
numdeck = [int(line) for line in f]
Is there a way to speed this up, especially given we know how many lines there are? (n).