Tuesday, July 2, 2024
HomeWordPress DevelopmentDiscover two integers such that at the very least one exists in...

Discover two integers such that at the very least one exists in every given Pair


  

def examine(x, y, arr, n):

  

    

    for i in vary(1, n):

        if arr[i][0] == y or arr[i][1] == y

                or arr[i][0] == x or arr[i][1] == x:

            proceed

        else:

  

            

            

            return True

    return False

  

  

def findIndex(x, arr, n):

    for i in vary(1, n):

        if arr[i][0] != x and arr[i][1] != x:

            return i

    return n

  

  

def discover(a, n):

    x = a[0][0]

    ok = findIndex(x, a, n)

  

    

    if ok >= n:

        return 'YES'

    y = a[k][0]

    flag = 0

  

    

    if examine(x, y, a, n):

  

        

        y = a[k][1]

  

        

        if examine(x, y, a, n):

  

            

            x = a[0][1]

            ok = findIndex(x, a, n)

            if ok >= n:

                return 'YES'

  

            

            y = a[k][0]

            if examine(x, y, a, n):

  

                

                y = a[k][1]

                if examine(x, y, a, n):

                    return 'NO'

    return 'YES'

  

  

if __name__ == '__main__':

    N = 6

    M = 5

    arr = [[2, 3], [2, 4], [2, 5], [3, 4], [3, 5], [4, 5]]

  

    

    print(discover(arr, N))

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments