Java Solution 100% without DP or Segment trees
Approach\n Describe your approach to solving the problem. \n1. For each query, update the specified element in the array.\n\n2. Recalculate the maximum sum of n
# Approach\n<!-- Describe your approach to solving the problem. -->\n1. For each query, update the specified element in the array.\n\n2. Recalculate the maximum sum of non-adjacent elements for the updated array.\n\n3. Sum up the results of each query.\n\n# Complexity\n- Time complexity: O(qn)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\npublic class Solution {\n    public static long maxNonAdjacentSum(int[] a){\n        if (a.length==0) return 0;\n        if (a.length == 1){ \n            if(a[0]>=0) return a[0];\n            else return 0;\n        }\n        long take = a[0];\n        long nottake = 0;\n        for (int i = 1; i < a.length; i++) {\n            long temp = Math.max(take, nottake);\n            take = nottake + a[i];\n            nottake = temp;\n        }\n        return Math.max(take, nottake);\n    }\n    public static int maximumSumSubsequence(int[] a,int[][] que){\n        long ans=0,sum;        \n        for (int[] q : que) {\n            int i=q[0];\n            int x=q[1];\n            a[i]=x;\n            sum=maxNonAdjacentSum(a);\n            ans+=sum;\n        }\n        ans=ans%1000000007;\n        return (int)ans;\n    }\n}\n\n```
['Java']