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

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

Please help me with some doubts, I was reading 2D BIT, gfg implementation https://www.geeksforgeeks.org/two-dimensional-binary-indexed-tree-or-fenwick-tree/

In the updateBit and getSum function inner loop, "y" is not initialized again, can someone explain me how is it working and what is the need of outer loop as the same work can be done with the help of an "if" statement.

Thanks in advance..

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

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

That's just wrong, you should initialize y on each step with the value of the query. You better check the link to topcoder in a reference section of this article.