def diff_commonPrefix(self, text1, text2):
    """Determine the common prefix of two strings.

    Args:
      text1: First string.
      text2: Second string.

    Returns:
      The number of characters common to the start of each string.
    """
    # Quick check for common null cases.
    if not text1 or not text2 or text1[0] != text2[0]:
      return 0
    # Binary search.
    # Performance analysis: https://neil.fraser.name/news/2007/10/09/
    pointermin = 0
    pointermax = min(len(text1), len(text2))
    pointermid = pointermax
    pointerstart = 0
    while pointermin < pointermid:
      if text1[pointerstart:pointermid] == text2[pointerstart:pointermid]:
        pointermin = pointermid
        pointerstart = pointermin
      else:
        pointermax = pointermid
      pointermid = (pointermax - pointermin) // 2 + pointermin
    return pointermid
def diff_commonPrefix ( self , text1 , text2 ) : if not text1 or not text2 or text1 [ 0 ] != text2 [ 0 ] : return 0 pointermin = 0 pointermax = min ( len ( text1 ) , len ( text2 ) ) pointermid = pointermax pointerstart = 0 while pointermin < pointermid : if text1 [ pointerstart : pointermid ] == text2 [ pointerstart : pointermid ] : pointermin = pointermid pointerstart = pointermin else : pointermax = pointermid pointermid = ( pointermax - pointermin ) // 2 + pointermin return pointermid
Determine the common prefix of two strings.

    Args:
      text1: First string.
      text2: Second string.

    Returns:
      The number of characters common to the start of each string.