💥💥 Beats 100% on runtime and memory [EXPLAINED]
IntuitionUpdate values in an array and calculating the maximum sum subsequence after each update. We need to efficiently compute this maximum sum by adjusting t
# Intuition
Update values in an array and calculating the maximum sum subsequence after each update. We need to efficiently compute this maximum sum by adjusting the values without recalculating from scratch every time, so we use a segment tree.

# Approach
We build a segment tree where each node stores the maximum subsequence sum for its range, considering possible subsequences that include or exclude the current element; then, we update the tree when a value changes and query the root to get the result.

# Complexity
- Time complexity:
O(log N) for both updates and queries due to the segment tree's structure.

- Space complexity:
O(N) for storing the segment tree.

# Code
```kotlin []
const val MOD = 1_000_000_007

class Solution {
    fun maximumSumSubsequence(nums: IntArray, queries: Array<IntArray>): Int {
        val n = nums.size
        val seg = Array(4 * n) { LongArray(4) { 0L } }

        // Push-Up Logic to consolidate segment results
        fun pushUp(ind: Int) {
            seg[ind][0] = maxOf(seg[2 * ind + 1][0] + seg[2 * ind + 2][0], 
                                maxOf(seg[2 * ind + 1][1] + seg[2 * ind + 2][0], 
                                      seg[2 * ind + 1][0] + seg[2 * ind + 2][2]))
            seg[ind][1] = maxOf(seg[2 * ind + 1][0] + seg[2 * ind + 2][1], 
                                maxOf(seg[2 * ind + 1][1] + seg[2 * ind + 2][1], 
                                      seg[2 * ind + 1][0] + seg[2 * ind + 2][3]))
            seg[ind][2] = maxOf(seg[2 * ind + 1][2] + seg[2 * ind + 2][0], 
                                maxOf(seg[2 * ind + 1][3] + seg[2 * ind + 2][0], 
                                      seg[2 * ind + 1][2] + seg[2 * ind + 2][2]))
            seg[ind][3] = maxOf(seg[2 * ind + 1][2] + seg[2 * ind + 2][1], 
                                maxOf(seg[2 * ind + 1][3] + seg[2 * ind + 2][1], 
                                      seg[2 * ind + 1][2] + seg[2 * ind + 2][3]))
        }

        // Build the segment tree
        fun build(ind: Int, low: Int, high: Int) {
            if (low == high) {
                seg[ind][0] = 0
                seg[ind][1] = Int.MIN_VALUE.toLong()
                seg[ind][2] = Int.MIN_VALUE.toLong()
                seg[ind][3] = nums[low].toLong()
                return
            }
            val mid = (low + high) / 2
            build(2 * ind + 1, low, mid)
            build(2 * ind + 2, mid + 1, high)
            pushUp(ind)
        }

        // Update the segment tree with the new value
        fun update(ind: Int, low: Int, high: Int, k: Int, valUpdate: Int) {
            if (low > k || high < k) return
            if (low == high && low == k) {
                seg[ind][0] = 0
                seg[ind][3] = valUpdate.toLong()
                return
            }
            val mid = (low + high) / 2
            update(2 * ind + 1, low, mid, k, valUpdate)
            update(2 * ind + 2, mid + 1, high, k, valUpdate)
            pushUp(ind)
        }

        // Initialize the segment tree
        build(0, 0, n - 1)

        var result = 0L
        for (query in queries) {
            val k = query[0]
            val valUpdate = query[1]
            update(0, 0, n - 1, k, valUpdate)
            result = (result + maxOf(seg[0][0], maxOf(seg[0][1], maxOf(seg[0][2], seg[0][3])))) % MOD
        }

        return result.toInt()
    }
}

```
['Array', 'Divide and Conquer', 'Dynamic Programming', 'Binary Indexed Tree', 'Segment Tree', 'Memoization', 'Kotlin']