[Java] Simple Iterative Solution | No DP needed
The runtime is pretty big but it passes...\n# Code\n\nclass Solution {\n    public int maximumSumSubsequence(int[] nums, int[][] q) {\n        int n = nums.leng
The runtime is pretty big but it passes...\n# Code\n```\nclass Solution {\n    public int maximumSumSubsequence(int[] nums, int[][] q) {\n        int n = nums.length;\n        long res = 0;\n        int MOD = (int)1e9 + 7;\n        long sum = 0;\n        for (int i = 0; i < q.length; i++) {\n            // If same element at i, use previous sum\n            // and save some computation\n            if (i != 0 && nums[q[i][0]] == q[i][1]) {\n                res = (res + sum)%MOD;\n                continue;\n            }\n            nums[q[i][0]] = q[i][1];\n            long tmp = sub(n, nums);\n            res = (res + tmp)%MOD;\n            sum = tmp;\n        }\n        return (int) res;\n    }\n    \n    // Method to find subsequence sum in O(N)\n    public int sub(int n, int[] arr) {\n        int yes = arr[0];\n        int no = 0;\n        int mx;\n\n        for (int i = 1; i < n; i++) {\n            mx = Math.max(yes, no);\n            yes = no + arr[i];\n            no = mx;\n        }\n        return Math.max(yes, no);\n    }\n    \n}\n```
['Java']