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

Автор I_love_HellHoleStudios, история, 6 лет назад, По-английски

I don't know if this trick was introduced or named earlier. But I found it interesting and decided to write a blog about it. The trick is simple and I wrote the blog simple too. Hope you don't get confused.

Link

Please ignore the Chinese interface.

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

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

Using set seems overcomplicated because you can solve the problem mentioned in the blog without set at all just keeping current minimum and delta.

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

This trick indeed has a name, it's offset. It allows adding something to all elements of a set.

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

I dont understand how to execute operation 1, how is the delta added to all of the elements in the set?

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

Might be irrelevant but, Here's the same question but with Xor as an operation: For the Curious Ones!

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

Wow, the trick is amazing trick. Something new for me to learn today.

This trick using set will be more useful when there is one more query to be performed: delete element X. Just remove element (X − δ) from the set or treemap (in Java), and there you go.