text: Minimum number of points to be removed to get remaining points on one side of axis | CPP program to find minimum points to be moved so that all points are on same side . ; Structure to store the coordinates of a point . ; Function to find the minimum number of points ; Number of points on the left of Y - axis . ; Number of points on the right of Y - axis . ; Number of points above X - axis . ; Number of points below X - axis . ; Driver Function
code: #include <bits/stdc++.h> NEW_LINE using namespace std ; typedef long long ll ; struct Point { int x , y ; } ; int findmin ( Point p [ ] , int n ) { int a = 0 , b = 0 , c = 0 , d = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( p [ i ] . x <= 0 ) a ++ ; else if ( p [ i ] . x >= 0 ) b ++ ; if ( p [ i ] . y >= 0 ) c ++ ; else if ( p [ i ] . y <= 0 ) d ++ ; } return min ( { a , b , c , d } ) ; } int main ( ) { Point p [ ] = { { 1 , 1 } , { 2 , 2 } , { -1 , -1 } , { -2 , 2 } } ; int n = sizeof ( p ) / sizeof ( p [ 0 ] ) ; cout << findmin ( p , n ) ; return 0 ; }