Missing vertex among N axis | Java Program to implement the above approach ; Driver Code ; Number of rectangles ; Stores the coordinates ; Insert the coordinates
import java . util . * ; class GFG { static class pair { int first , second ; public pair ( int first , int second ) { this . first = first ; this . second = second ; } } static void MissingPoint ( Vector < pair > V , int N ) { HashMap < Integer , Integer > mp = new HashMap < Integer , Integer > ( ) ; for ( int i = 0 ; i < V . size ( ) ; i ++ ) { if ( mp . containsKey ( V . get ( i ) . first ) ) mp . put ( V . get ( i ) . first , V . get ( i ) . first + 1 ) ; else mp . put ( V . get ( i ) . first , 1 ) ; } int x = 0 , y = 0 ; for ( Map . Entry < Integer , Integer > it : mp . entrySet ( ) ) { if ( it . getValue ( ) % 2 == 1 ) { x = it . getKey ( ) ; break ; } } mp . clear ( ) ; for ( int i = 0 ; i < V . size ( ) ; i ++ ) { if ( mp . containsKey ( V . get ( i ) . second ) ) mp . put ( V . get ( i ) . second , V . get ( i ) . second + 1 ) ; else mp . put ( V . get ( i ) . second , 1 ) ; } for ( Map . Entry < Integer , Integer > it : mp . entrySet ( ) ) { if ( it . getValue ( ) % 2 == 1 ) { y = it . getKey ( ) ; break ; } } System . out . print ( x + " ▁ " + y ) ; } public static void main ( String [ ] args ) { int N = 2 ; Vector < pair > V = new Vector < pair > ( ) ; V . add ( new pair ( 1 , 1 ) ) ; V . add ( new pair ( 1 , 2 ) ) ; V . add ( new pair ( 4 , 6 ) ) ; V . add ( new pair ( 2 , 1 ) ) ; V . add ( new pair ( 9 , 6 ) ) ; V . add ( new pair ( 9 , 3 ) ) ; V . add ( new pair ( 4 , 3 ) ) ; MissingPoint ( V , N ) ; } }