Even though it says "data structure", all you need is ONE variable to record the larger value. The smaller value is always one less than the larger value. And then two more variables to record the count is sufficient.
BTW, and discussed in another thread, if you're also given the value of the most significant bit of n and k, you can have an O(1) solution as well. -- You received this message because you are subscribed to the Google Groups "Google Code Jam" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/google-code/21c7f0b1-3917-4b88-b405-74898478cdba%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
