// Given N points in a 2D Plane in a 2D matrix , return total numbers of distinct points
import java.util.*;
import java.lang.*;
import java.io.*;
// The main method must be in a class named "Main".
class Main {
public static int countDistinctPoint(int [][] point ){
int n = point.length;
HashSet<String> distinctPoint = new HashSet<>();
for(int i=0; i<n; i++){
String pointKey = point[i][0] + "#" + point[i][1];
distinctPoint.add(pointKey);
}
return distinctPoint.size();
}
public static void main(String[] args) {
int [][] point = {
{1,2},
{3,4},
{1,2},
{5,6},
{3,4}
};
System.out.println("Total Count :- " + countDistinctPoint(point));
}
}
To embed this project on your website, copy the following code and paste it into your website's HTML: