Concise C++ with detailed explanation
The problem seems pretty difficult at first sight, but when you put some thought into it, you\'ll figure that it\'s very simple!\n## Algorithm explanation with 
The problem seems pretty difficult at first sight, but when you put some thought into it, you\'ll figure that it\'s very simple!\n## Algorithm explanation with example:\n### Question in description:\n![image](https://assets.leetcode.com/users/images/05922281-3375-4383-8aaf-3e11147c3618_1596622523.888151.png)\nNow, lets modify the graphical representation a little bit to give us intuition on the algorithm:\n![image](https://assets.leetcode.com/users/images/72100733-5895-400e-bde1-cac0e55ab801_1596625536.6153824.png)\n\n## Note the following:\n1. In the above picture, we traverse through both the arrays. **x** is iterator for nums1 and **y** is iterator for nums2.\n\n2. We have to choose a path which starts from first element of either nums1 or nums2. Hence we\'ll initialize both **x** and **y** with 0.\n```\nlong long int x = 0, y = 0;\n```\n3. While traversing through both the arrays, we\'ll keep the maximum sum upto index **x** in **X** and maximum sum upto index **y** in **Y** variables respectively.\n```\nlong long int X = 0, Y = 0;\n```\n4. At the end after traversing through both the arrays, our answer is nothing but **max(X, Y)**\n## The Algorithm:\nSince we have to traverse along the arrays together, we move forward one index in one array at a time. Hence the **if** and **else if** conditions below.\n\nIn case of the **else** condition, it represents that our current location is at a common element. So we increment both the indices **x** as well as **y**. We also update the **X** and **Y** variables which represent the maximum sum upto index **x** and **y**.\n```\nwhile (x < nums1.size() and y < nums2.size() ) {\n\tif(nums1[x] < nums2[y])\n\t\tX += nums1[x++];\n\telse if (nums1[x] > nums2[y])\n\t\tY += nums2[y++];\n\telse {\n\t\tX = Y = nums1[x] + max(X, Y);\n\t\tx++;\n\t\ty++;\n\t}\n```\nThe above while loop terminates when one of the indices reach the last element of it\'s corresponding array. So we\'ll traverse and update the remainig array.\n```\nwhile(x < nums1.size()) X += nums1[x++];\nwhile(y < nums2.size()) Y += nums2[y++];\n```\nNow that we\'ve traversed both the arrays, let\'s return our answer!\n```\nreturn max(X, Y) % 1000000007;\n```\n**Feel free to comment any of your doubts or corrections, I\'m more than happy to clarify :)**
['C']