text: Minimum number of points to be removed to get remaining points on one side of axis | C # 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 Code
code: using System ; class GFG { public class Point { public int x , y ; public Point ( int x , int y ) { this . x = x ; this . y = y ; } } ; static 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 Math . Min ( Math . Min ( a , b ) , Math . Min ( c , d ) ) ; } public static void Main ( String [ ] args ) { Point [ ] p = { new Point ( 1 , 1 ) , new Point ( 2 , 2 ) , new Point ( - 1 , - 1 ) , new Point ( - 2 , 2 ) } ; int n = p . Length ; Console . WriteLine ( findmin ( p , n ) ) ; } }