Given two strings A and B, what's the longest prefix of A which is suffix of B.
Asked in the phone screen stage. Implement the function below and return the matching substring. If no non-empty match exists, return an empty string. When a matched prefix has a shorter matching border at the end of B, continue with that border, as required by the examples.
A and B are strings. Return a string containing the required prefix of A.
def longest_prefix_suffix(A, B):