public static int findMaxPathSum(int[] s1, int[] s2) {
        int i = 0 ;
        int j = 0;
        int maxSum1 = 0;
        int maxSum2 = 0;
        int maxResultSum = 0;

        while(true){
            if(i == s1.length || j == s2.length){
                break;
            }

            if(s1[i] < s2[j]){
                maxSum1 += s1[i++];

            } else if(s1[i] > s2[j]){
                maxSum2 += s2[j++];

            } else {
                maxSum1 += s1[i++];
                maxSum2 += s2[j++];
                maxResultSum += Math.max(maxSum1,maxSum2);
                maxSum1 = 0;
                maxSum2 = 0;
            }
        }

        while(i!=s1.length){
            maxResultSum += s1[i++];
        }

        while(j!=s2.length){
           maxResultSum += s2[j++];
        }


        return maxResultSum;
    }