title: Maximum Possible Sum Window Array Elements Window Array Unique
signature: func maximumPossibleSumWindowArrayElementsWindowArrayUnique(a []int, b []int, n int) int {
source_py: def maximum_possible_sum_window_array_elements_window_array_unique(A, B, n):
      mp = set()
      result = 0
      curr_sum = curr_begin = 0
      for i in range(0, n):
          while (A[i] in mp):
              mp.remove(A[curr_begin])
              curr_sum -= B[curr_begin]
              curr_begin += 1
          mp.add(A[i])
          curr_sum += B[i]
          result = max(result, curr_sum)
      return result
source_cpp: int maximum_possible_sum_window_array_elements_window_array_unique(vector<int> A, vector<int> B, int n) {
    unordered_set < int > mp;
    int result = 0;
    int curr_sum = 0, curr_begin = 0;
    for ( int i = 0;
    i < n;
    ++ i ) {
      while ( mp . find ( A [ i ] ) != mp . end ( ) ) {
        mp . erase ( A [ curr_begin ] );
        curr_sum -= B [ curr_begin ];
        curr_begin ++;
      }
      mp . insert ( A [ i ] );
      curr_sum += B [ i ];
      result = max ( result, curr_sum );
    }
    return result;
  }