Блог пользователя codolove

Автор codolove, 11 лет назад, По-английски

I am trying to solve this question from many days but getting wrong answe always. I am using a trie to solve this. My code is here.

  • Проголосовать: нравится
  • +9
  • Проголосовать: не нравится

»
11 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

I think you are trying to solve the same problem that are solving here. Check it out, maybe you find the answer there. I couldn't see your code due to technical problems but I solve similar problems using tries too, so I think you are probably on the right way.

»
11 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

I'll give you a hint, write the maximum number in binary, it's going to have at most 20 digits, now it's obvious that you can have only one of each digit in the answer, and having a digit i is better than having digits 1 . . . i-1 since 2^i > 1 + 2 + . . . + 2^(i-1), so now each time try saving the digit with the most value and your done!