Check if a point having maximum X and Y coordinates exists or not | Python3 program for the above approach ; Function to find the pohaving max X and Y coordinates ; Initialize maxX and maxY ; Length of the given array ; Get maximum X & Y coordinates ; Check if the required point i . e . , ( maxX , maxY ) is present ; If powith maximum X and Y coordinates is present ; If no such poexists ; Driver Code ; Given array of points ; Pranswer
import sys ; NEW_LINE def findMaxPoint ( arr ) : NEW_LINE INDENT maxX = - sys . maxsize ; NEW_LINE maxY = - sys . maxsize ; NEW_LINE n = len ( arr ) ; NEW_LINE for i in range ( n ) : NEW_LINE INDENT maxX = max ( maxX , arr [ i ] [ 0 ] ) ; NEW_LINE maxY = max ( maxY , arr [ i ] [ 1 ] ) ; NEW_LINE DEDENT for i in range ( n ) : NEW_LINE INDENT if ( maxX == arr [ i ] [ 0 ] and maxY == arr [ i ] [ 1 ] ) : NEW_LINE INDENT print ( " ( " , maxX , " , ▁ " , maxY , " ) " ) ; NEW_LINE return ; NEW_LINE DEDENT DEDENT print ( - 1 ) ; NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT arr = [ [ 1 , 2 ] , [ 2 , 1 ] , [ 3 , 4 ] , [ 4 , 3 ] , [ 5 , 5 ] ] ; NEW_LINE findMaxPoint ( arr ) ; NEW_LINE DEDENT