Easiest Well Explained & Commented Prefix and Suffix C++ Code
Intuition & Approach

Build Suffix Matches (rightPos):

We create an array rightPos of size m (length of t) initialized with -1.
A pointer right starts at the e
# Intuition & Approach
1. Build Suffix Matches (rightPos):

    - We create an array rightPos of size m (length of t) initialized with -1.
    - A pointer right starts at the end of t.
    - We scan s from right to left. Every time s[i] equals t[right], we store i in rightPos[right] and move right one step left.
    - This tells us for each character in t (when scanning from the right) where it can match in s.

2. Initial Answer:

    - If some characters from t could not be matched in the reverse scan, right remains ≥ 0.
    - We set ans = right + 1, which represents the cost of removing all characters up to the last unmatched index in t.

3. Match the Prefix and Adjust Suffix:

    - Use a pointer prefix to scan t from the left as you go through s.
    - For each match (s[i] == t[prefix]), ensure the suffix part starts after the current index i by moving the right pointer forward until rightPos[right] > i.
    - The removal cost here is the gap between the end of the prefix (prefix) and the beginning of the suffix (right), computed as right - (prefix + 1).
    - Update ans with the minimum removal cost found.

4. Return the Minimum Removal Cost:

    - After scanning through s, the smallest removal block length required to make t a subsequence of s is stored in ans.

This approach effectively splits t into a matched prefix and suffix (using rightPos), and the gap between these two parts gives the answer.

# Complexity
- Time complexity:
$$O(n+m)$$

- Space complexity:
$$O(m)$$

# Code
```cpp []
class Solution {
public:
    int minimumScore(string s, string t) {
        int n = s.size(), m = t.size();
        // to store for each idx in t, the idx in s that matches it when matching from right to left
        vector<int> rightPos(m, -1); 
        int right = m-1; // pointer to start t from right to left
        for(int i = n-1; i >= 0 && right >= 0; i--){
            if(s[i] == t[right]){ // match found
                rightPos[right] = i;
                right--; // mpve to prev char in t
            }
        }
        int ans = right+1; // possible ans is to remove chars from 0 to last matched idx
        int prefix = 0; // pointer for t prefix from left to right
        for(int i = 0; i < n && prefix < m && ans > 0; i++){
            if(s[i] == t[prefix]){ // match found
                // we want suffix pointer to be strictly placed after curr matched i in s
                while(right < m && rightPos[right] <= i){right++;} 
                // removal cost is no of chars  removed from t b/w the matched prefix(ending at t[prefix]) and the start of suffix(at t[right])
                ans = min(ans, right-(prefix+1));
                prefix++; // move to next char in t
            }
        }
        return ans;
    }
};
```
['Two Pointers', 'String', 'C++']