Rakim
banner
rakim0.bsky.social
Rakim
@rakim0.bsky.social
I like backend, ricing and manga.
Currently focusing on leetcode
IIITA'26
Checkout what I'm currently working on here:
https://rakim.bearblog.dev/devlog/
Took a while since I forgot recursion is a thing 🫥
December 11, 2024 at 10:28 AM
Here's a CF blog explaining this idea: codeforces.com/blog/entry/7...
An Introduction To Difference Arrays - Codeforces
codeforces.com
December 9, 2024 at 8:40 PM
So the problem basically boils down to:
Update in O(1): You have to add 1 to all numbers [l, r]
Print final: O(n)

Reading the usaco.guide hints, I got to know that this is opposite of prefix sum!
So what we can do is keep track of differences and then use that to build the final array!
USACO Guide
A free collection of curated, high-quality competitive programming resources to take you from USACO Bronze to USACO Platinum and beyond. Written by top USACO Finalists, these tutorials will guide you ...
usaco.guide
December 9, 2024 at 8:37 PM