Animation for CMSC398L Week 10
We sort the queries by left boundary from right to left, and process them in order
3 2 3 1 2 1 5
\(l\)
\(r\)
We sort the queries by left boundary from right to left, and process them in order
3 2 3 1 2 1 5
\(l\)
\(r\)
We sort the queries by left boundary from right to left, and process them in order
3 2 3 1 2 1 5
\(l\)
\(r\)
We sort the queries by left boundary from right to left, and process them in order
3 2 3 1 2 1 5
\(l\)
\(r\)
We sort the queries by left boundary from right to left, and process them in order
3 2 3 1 2 1 5
\(l\)
\(r\)
We sort the queries by left boundary from right to left, and process them in order
3 2 3 1 2 1 5
\(l\)
\(r\)
We sort the queries by left boundary from right to left, and process them in order
3 2 3 1 2 1 5
\(l\)
\(r\)
Notice that for each number, the range it contributes would be starting from $i$ until the next same value shows up
3 2 3 1 2 1 5
\(l\)
\(r\)
(Red line means the contribution of \(a_l\))
3 2 3 1 2 1 5
\(l\)
\(r\)
(Red line means the contribution of \(a_l\))
3 2 3 1 2 1 5
\(l\)
\(r\)
(Red line means the contribution of \(a_l\))
3 2 3 1 2 1 5
\(l\)
\(r\)
(Red line means the contribution of \(a_l\))
3 2 3 1 2 1 5
\(l\)
\(r\)
(Red line means the contribution of \(a_l\))
3 2 3 1 2 1 5
\(l\)
\(r\)
(Red line means the contribution of \(a_l\))
3 2 3 1 2 1 5
\(l\)
\(r\)
(Red line means the contribution of \(a_l\))
3 2 3 1 2 1 5
\(l\)
\(r\)
Therefore, we can solve the problem with any data structure that supports range add/point query
3 2 3 1 2 1 5
\(l\)
\(r\)
Animation for CMSC398L Week 10
By sam571128
Animation for CMSC398L Week 10
- 103