c++ using loop and vector only
Intuition\n Describe your first thoughts on how to solve this problem. \nif sum of( nums1[j]+nums2[j]) is less than queries[j][0]+queries[j][1] then surely ther
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nif sum of( nums1[j]+nums2[j]) is less than queries[j][0]+queries[j][1] then surely there will be no element.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nfirst we store the sum of num1 and num2 each element with there both number so that we can sort that and it will help us in finding those number.\nnext we checked if the sum is greater and fulfilling the criteria than we add that the number to vector else -1;\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nO(n)\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nO(3n)\n\n# Code\n```\nclass Solution {\npublic:\n    vector<int> maximumSumQueries(vector<int>& nums1, vector<int>& nums2, vector<vector<int>>& queries) {\n        vector<vector<int>> v;\n        int n=nums1.size();\n        for(int i=0;i<n;i++){\n            vector<int> g;\n            g.push_back(nums1[i]+nums2[i]);\n            g.push_back(nums1[i]);\n            g.push_back(nums2[i]);\n            v.push_back(g);\n        }\n        sort(v.begin(),v.end());\n       \n        vector<int> f;\n        int s=0;\n        for(int j=n-1;j>=0;j--){\n               \n                if(v[j][0]>=queries[0][0]+queries[0][1]){\n                    if(queries[0][0]<=v[j][1] and queries[0][1]<=v[j][2]){\n                        s=1;\n                        f.push_back(v[j][0]);\n                        break;\n                    }\n                }\n                else{\n                    break;\n                }\n               \n            }\n            if(s==0){\n                f.push_back(-1);\n            }\n        for(int i=1;i<queries.size();i++){\n           \n            if(queries[i]==queries[i-1]){\n                int g=f[i-1];\n                f.push_back(g);\n            }\n            else{\n                 int a=0;\n                 \n            for(int j=n-1;j>=0;j--){\n               int t=v[j][0];\n                if(t>=queries[i][0]+queries[i][1]){\n                    if(queries[i][0]<=v[j][1] and queries[i][1]<=v[j][2]){\n                        a=1;\n                        f.push_back(t);\n                        break;\n                    }\n                }\n                else{\n                    break;\n                }\n               \n            }\n            if(a==0){\n                f.push_back(-1);\n            }}\n            \n        }\n        return f;\n    }\n};\n```
['Array', 'Binary Search', 'Stack', 'C++']