Practice Maximum Sum of Subsequence With Non-adjacent Elements
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Maximum Sum of Subsequence With Non-adjacent Elements
Problem Statement
You are given an array nums consisting of integers. You are also given a 2D array queries, where queries[i] = [posi, xi]. For query i, we first set nums[posi] equal to xi, then we calculate the answer to query i which is the maximum sum of a subsequence of nums where no two adjacent elements are selected. Return the sum of the answers to all queries. Since the final answer may be very large, return it modulo 10^9 + 7. A subsequence is an array that can be derived from another array by deleting some or no elements without changing the order of the remaining elements.
Source: Maximum Sum of Subsequence With Non-adjacent Elements on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
nums = [3,5,9], queries = [[1,-2],[0,-3]]
21
# Example 2
nums = [0,-1], queries = [[0,-5]]
0
Constraints
Related LeetCode Problems
Practice more problems similar to Maximum Sum of Subsequence With Non-adjacent Elements.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.