We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • Practice
  • Certification
  • Compete
  • Career Fair
  • Hiring developers?
  1. Practice
  2. Data Structures
  3. Arrays
  4. Array Manipulation
  5. Discussions

Array Manipulation

Problem
Submissions
Leaderboard
Discussions
Editorial

    You are viewing a single comment's thread. Return to all comments →

  • nivdatta88 4 years ago+ 0 comments

    I still have some doubt if anyone could explain it. I understand that it is making use of difference array to keep track of the difference between items rather than updating every item.

    However as I understand, size of difference array is one less than total items in the actual array.

    So as per the demo program given,

          	  ARR						DIFF
    (5,3)  0    0    0    0    0		0    0     0    0
    (1,2)  100  100  0    0    0		0    -100  0    0
    (2,5)  100  200  100  100  100		100  -100  0    0
    (3,4)  100  200  200  200  100		100  0     0    -100
    

    However the logic used seems to be a variant of difference array that I am not able to understand. It would be great if someone could help me connect the dots from this difference array to the actual working solution of this problem. Thanks.

    1|
    ParentPermalink
  • Contest Calendar
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy
  • Request a Feature