Similar Strings

  • + 0 comments

    In Python, I had to change the source code of the main routine, because it was giving errors. Below is the modified source code, before solving the problem:

    #!/bin/python3
    
    import math
    import os
    import random
    import re
    import sys
    
    #
    # Complete the 'similarStrings' function below.
    #
    # The function is expected to return an INTEGER_ARRAY.
    # The function accepts following parameters:
    #  1. INTEGER n
    #  2. 2D_INTEGER_ARRAY queries
    #
    
    def similarStrings(word, queries):
        # Write your code here
    
    if __name__ == '__main__':
        fptr = open(os.environ['OUTPUT_PATH'], 'w')
    
        first_multiple_input = input().rstrip().split()
    
        n = int(first_multiple_input[0])
    
        q = int(first_multiple_input[1])
        
        word = input().rstrip().split()[0]
    
        queries = []
    
        for _ in range(q):
            queries.append(list(map(int, input().rstrip().split())))
    
        result = similarStrings(word, queries)
    
        fptr.write('\n'.join(map(str, result)))
        fptr.write('\n')
    
        fptr.close()