Most intuitive and easy approach
Intuition\n Describe your first thoughts on how to solve this problem. \nwe are storing the values of queries in a new array nums\nwhere nums[arr[0]]=arr[1];\nt
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nwe are storing the values of queries in a new array nums\nwhere nums[arr[0]]=arr[1];\nthen we are returning the sum of each array with the help of dp\n\nIn dp we made an array and replaced all negetive element with 0\nInitialized the array with nums[1] and nums[2] after changing the query and then performed the algorithm to find the maximum sum of\nadjacent element\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n- length of numsXqueries\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n- 0(n) Just An extra array is taken \n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n    public int maximumSumSubsequence(int[] nums, int[][] queries) {\n        long s=0;\n        for( int []arr:queries){\n            nums[arr[0]]=arr[1];\n            s=(s+sum(nums))%1000000007;                      \n\n        }return (int)s;\n        \n    }\n    private int sum(int nums[]){\n        int n=nums.length;\n        int dp[]=new int[n]; \n        Arrays.fill(dp,0);\n        if(n==1) {\n            return nums[0]>=0?nums[0]:0;\n        }else if(n==2) {\n            int jj=Math.max(nums[0],nums[1]);\n            return jj>=0?jj:0;\n        }\n        else{\n            dp[0]=nums[0]>=0?nums[0]:0;\n        dp[1]=nums[1]>=0?nums[1]:0;\n            dp[1]=Math.max(dp[0],dp[1]);\n        \n        \n        for( int i=2;i<n;i++){\n                    nums[i]=nums[i]>=0?nums[i]:0;\n\n            dp[i]=Math.max((nums[i]+dp[i-2]),dp[i-1]);\n            \n        }\n        return dp[n-1]%1000000007;\n}\n    }\n}\n```
['Java']