A diamond is a quadrilateral whose four sides all have the same length and whose diagonals are parallel to the coordinate axes.
You are given N distinct points on a plane. Count the number of different diamonds that can be constructed using these points as vertices (two diamonds are different if their sets of vertices are different). Do not count diamonds whose area is empty.
Write a function:
int solution(int X[], int Y[], int N);
that, given two arrays X and Y, each containing N integers, representing N points (where X[K], Y[K] are the coordinates of the K-th point), returns the number of diamonds on the plane.
For example, for N = 7 points whose coordinates are specified in arrays X = [1, 1, 2, 2, 2, 3, 3] and Y = [3, 4, 1, 3, 5, 3, 4], the function should return 2, since we can find two diamonds as shown in the picture below:
Given arrays: X = [1, 2, 3, 3, 2, 1], Y = [1, 1, 1, 2, 2, 2], the function should return 0, since there are no diamonds on the plane:
Write an efficient algorithm for the following assumptions:
- N is an integer within the range [4..1,500];
- each element of arrays X and Y is an integer within the range [0..N-1];
- given N points are pairwise distinct.
A diamond is a quadrilateral whose four sides all have the same length and whose diagonals are parallel to the coordinate axes.
You are given N distinct points on a plane. Count the number of different diamonds that can be constructed using these points as vertices (two diamonds are different if their sets of vertices are different). Do not count diamonds whose area is empty.
Write a function:
int solution(vector<int> &X, vector<int> &Y);
that, given two arrays X and Y, each containing N integers, representing N points (where X[K], Y[K] are the coordinates of the K-th point), returns the number of diamonds on the plane.
For example, for N = 7 points whose coordinates are specified in arrays X = [1, 1, 2, 2, 2, 3, 3] and Y = [3, 4, 1, 3, 5, 3, 4], the function should return 2, since we can find two diamonds as shown in the picture below:
Given arrays: X = [1, 2, 3, 3, 2, 1], Y = [1, 1, 1, 2, 2, 2], the function should return 0, since there are no diamonds on the plane:
Write an efficient algorithm for the following assumptions:
- N is an integer within the range [4..1,500];
- each element of arrays X and Y is an integer within the range [0..N-1];
- given N points are pairwise distinct.
A diamond is a quadrilateral whose four sides all have the same length and whose diagonals are parallel to the coordinate axes.
You are given N distinct points on a plane. Count the number of different diamonds that can be constructed using these points as vertices (two diamonds are different if their sets of vertices are different). Do not count diamonds whose area is empty.
Write a function:
int solution(vector<int> &X, vector<int> &Y);
that, given two arrays X and Y, each containing N integers, representing N points (where X[K], Y[K] are the coordinates of the K-th point), returns the number of diamonds on the plane.
For example, for N = 7 points whose coordinates are specified in arrays X = [1, 1, 2, 2, 2, 3, 3] and Y = [3, 4, 1, 3, 5, 3, 4], the function should return 2, since we can find two diamonds as shown in the picture below:
Given arrays: X = [1, 2, 3, 3, 2, 1], Y = [1, 1, 1, 2, 2, 2], the function should return 0, since there are no diamonds on the plane:
Write an efficient algorithm for the following assumptions:
- N is an integer within the range [4..1,500];
- each element of arrays X and Y is an integer within the range [0..N-1];
- given N points are pairwise distinct.
A diamond is a quadrilateral whose four sides all have the same length and whose diagonals are parallel to the coordinate axes.
You are given N distinct points on a plane. Count the number of different diamonds that can be constructed using these points as vertices (two diamonds are different if their sets of vertices are different). Do not count diamonds whose area is empty.
Write a function:
class Solution { public int solution(int[] X, int[] Y); }
that, given two arrays X and Y, each containing N integers, representing N points (where X[K], Y[K] are the coordinates of the K-th point), returns the number of diamonds on the plane.
For example, for N = 7 points whose coordinates are specified in arrays X = [1, 1, 2, 2, 2, 3, 3] and Y = [3, 4, 1, 3, 5, 3, 4], the function should return 2, since we can find two diamonds as shown in the picture below:
Given arrays: X = [1, 2, 3, 3, 2, 1], Y = [1, 1, 1, 2, 2, 2], the function should return 0, since there are no diamonds on the plane:
Write an efficient algorithm for the following assumptions:
- N is an integer within the range [4..1,500];
- each element of arrays X and Y is an integer within the range [0..N-1];
- given N points are pairwise distinct.
A diamond is a quadrilateral whose four sides all have the same length and whose diagonals are parallel to the coordinate axes.
You are given N distinct points on a plane. Count the number of different diamonds that can be constructed using these points as vertices (two diamonds are different if their sets of vertices are different). Do not count diamonds whose area is empty.
Write a function:
int solution(List<int> X, List<int> Y);
that, given two arrays X and Y, each containing N integers, representing N points (where X[K], Y[K] are the coordinates of the K-th point), returns the number of diamonds on the plane.
For example, for N = 7 points whose coordinates are specified in arrays X = [1, 1, 2, 2, 2, 3, 3] and Y = [3, 4, 1, 3, 5, 3, 4], the function should return 2, since we can find two diamonds as shown in the picture below:
Given arrays: X = [1, 2, 3, 3, 2, 1], Y = [1, 1, 1, 2, 2, 2], the function should return 0, since there are no diamonds on the plane:
Write an efficient algorithm for the following assumptions:
- N is an integer within the range [4..1,500];
- each element of arrays X and Y is an integer within the range [0..N-1];
- given N points are pairwise distinct.
A diamond is a quadrilateral whose four sides all have the same length and whose diagonals are parallel to the coordinate axes.
You are given N distinct points on a plane. Count the number of different diamonds that can be constructed using these points as vertices (two diamonds are different if their sets of vertices are different). Do not count diamonds whose area is empty.
Write a function:
func Solution(X []int, Y []int) int
that, given two arrays X and Y, each containing N integers, representing N points (where X[K], Y[K] are the coordinates of the K-th point), returns the number of diamonds on the plane.
For example, for N = 7 points whose coordinates are specified in arrays X = [1, 1, 2, 2, 2, 3, 3] and Y = [3, 4, 1, 3, 5, 3, 4], the function should return 2, since we can find two diamonds as shown in the picture below:
Given arrays: X = [1, 2, 3, 3, 2, 1], Y = [1, 1, 1, 2, 2, 2], the function should return 0, since there are no diamonds on the plane:
Write an efficient algorithm for the following assumptions:
- N is an integer within the range [4..1,500];
- each element of arrays X and Y is an integer within the range [0..N-1];
- given N points are pairwise distinct.
A diamond is a quadrilateral whose four sides all have the same length and whose diagonals are parallel to the coordinate axes.
You are given N distinct points on a plane. Count the number of different diamonds that can be constructed using these points as vertices (two diamonds are different if their sets of vertices are different). Do not count diamonds whose area is empty.
Write a function:
class Solution { public int solution(int[] X, int[] Y); }
that, given two arrays X and Y, each containing N integers, representing N points (where X[K], Y[K] are the coordinates of the K-th point), returns the number of diamonds on the plane.
For example, for N = 7 points whose coordinates are specified in arrays X = [1, 1, 2, 2, 2, 3, 3] and Y = [3, 4, 1, 3, 5, 3, 4], the function should return 2, since we can find two diamonds as shown in the picture below:
Given arrays: X = [1, 2, 3, 3, 2, 1], Y = [1, 1, 1, 2, 2, 2], the function should return 0, since there are no diamonds on the plane:
Write an efficient algorithm for the following assumptions:
- N is an integer within the range [4..1,500];
- each element of arrays X and Y is an integer within the range [0..N-1];
- given N points are pairwise distinct.
A diamond is a quadrilateral whose four sides all have the same length and whose diagonals are parallel to the coordinate axes.
You are given N distinct points on a plane. Count the number of different diamonds that can be constructed using these points as vertices (two diamonds are different if their sets of vertices are different). Do not count diamonds whose area is empty.
Write a function:
class Solution { public int solution(int[] X, int[] Y); }
that, given two arrays X and Y, each containing N integers, representing N points (where X[K], Y[K] are the coordinates of the K-th point), returns the number of diamonds on the plane.
For example, for N = 7 points whose coordinates are specified in arrays X = [1, 1, 2, 2, 2, 3, 3] and Y = [3, 4, 1, 3, 5, 3, 4], the function should return 2, since we can find two diamonds as shown in the picture below:
Given arrays: X = [1, 2, 3, 3, 2, 1], Y = [1, 1, 1, 2, 2, 2], the function should return 0, since there are no diamonds on the plane:
Write an efficient algorithm for the following assumptions:
- N is an integer within the range [4..1,500];
- each element of arrays X and Y is an integer within the range [0..N-1];
- given N points are pairwise distinct.
A diamond is a quadrilateral whose four sides all have the same length and whose diagonals are parallel to the coordinate axes.
You are given N distinct points on a plane. Count the number of different diamonds that can be constructed using these points as vertices (two diamonds are different if their sets of vertices are different). Do not count diamonds whose area is empty.
Write a function:
function solution(X, Y);
that, given two arrays X and Y, each containing N integers, representing N points (where X[K], Y[K] are the coordinates of the K-th point), returns the number of diamonds on the plane.
For example, for N = 7 points whose coordinates are specified in arrays X = [1, 1, 2, 2, 2, 3, 3] and Y = [3, 4, 1, 3, 5, 3, 4], the function should return 2, since we can find two diamonds as shown in the picture below:
Given arrays: X = [1, 2, 3, 3, 2, 1], Y = [1, 1, 1, 2, 2, 2], the function should return 0, since there are no diamonds on the plane:
Write an efficient algorithm for the following assumptions:
- N is an integer within the range [4..1,500];
- each element of arrays X and Y is an integer within the range [0..N-1];
- given N points are pairwise distinct.
A diamond is a quadrilateral whose four sides all have the same length and whose diagonals are parallel to the coordinate axes.
You are given N distinct points on a plane. Count the number of different diamonds that can be constructed using these points as vertices (two diamonds are different if their sets of vertices are different). Do not count diamonds whose area is empty.
Write a function:
fun solution(X: IntArray, Y: IntArray): Int
that, given two arrays X and Y, each containing N integers, representing N points (where X[K], Y[K] are the coordinates of the K-th point), returns the number of diamonds on the plane.
For example, for N = 7 points whose coordinates are specified in arrays X = [1, 1, 2, 2, 2, 3, 3] and Y = [3, 4, 1, 3, 5, 3, 4], the function should return 2, since we can find two diamonds as shown in the picture below:
Given arrays: X = [1, 2, 3, 3, 2, 1], Y = [1, 1, 1, 2, 2, 2], the function should return 0, since there are no diamonds on the plane:
Write an efficient algorithm for the following assumptions:
- N is an integer within the range [4..1,500];
- each element of arrays X and Y is an integer within the range [0..N-1];
- given N points are pairwise distinct.
A diamond is a quadrilateral whose four sides all have the same length and whose diagonals are parallel to the coordinate axes.
You are given N distinct points on a plane. Count the number of different diamonds that can be constructed using these points as vertices (two diamonds are different if their sets of vertices are different). Do not count diamonds whose area is empty.
Write a function:
function solution(X, Y)
that, given two arrays X and Y, each containing N integers, representing N points (where X[K], Y[K] are the coordinates of the K-th point), returns the number of diamonds on the plane.
For example, for N = 7 points whose coordinates are specified in arrays X = [1, 1, 2, 2, 2, 3, 3] and Y = [3, 4, 1, 3, 5, 3, 4], the function should return 2, since we can find two diamonds as shown in the picture below:
Given arrays: X = [1, 2, 3, 3, 2, 1], Y = [1, 1, 1, 2, 2, 2], the function should return 0, since there are no diamonds on the plane:
Write an efficient algorithm for the following assumptions:
- N is an integer within the range [4..1,500];
- each element of arrays X and Y is an integer within the range [0..N-1];
- given N points are pairwise distinct.
Note: All arrays in this task are zero-indexed, unlike the common Lua convention. You can use #A to get the length of the array A.
A diamond is a quadrilateral whose four sides all have the same length and whose diagonals are parallel to the coordinate axes.
You are given N distinct points on a plane. Count the number of different diamonds that can be constructed using these points as vertices (two diamonds are different if their sets of vertices are different). Do not count diamonds whose area is empty.
Write a function:
int solution(NSMutableArray *X, NSMutableArray *Y);
that, given two arrays X and Y, each containing N integers, representing N points (where X[K], Y[K] are the coordinates of the K-th point), returns the number of diamonds on the plane.
For example, for N = 7 points whose coordinates are specified in arrays X = [1, 1, 2, 2, 2, 3, 3] and Y = [3, 4, 1, 3, 5, 3, 4], the function should return 2, since we can find two diamonds as shown in the picture below:
Given arrays: X = [1, 2, 3, 3, 2, 1], Y = [1, 1, 1, 2, 2, 2], the function should return 0, since there are no diamonds on the plane:
Write an efficient algorithm for the following assumptions:
- N is an integer within the range [4..1,500];
- each element of arrays X and Y is an integer within the range [0..N-1];
- given N points are pairwise distinct.
A diamond is a quadrilateral whose four sides all have the same length and whose diagonals are parallel to the coordinate axes.
You are given N distinct points on a plane. Count the number of different diamonds that can be constructed using these points as vertices (two diamonds are different if their sets of vertices are different). Do not count diamonds whose area is empty.
Write a function:
function solution(X: array of longint; Y: array of longint; N: longint): longint;
that, given two arrays X and Y, each containing N integers, representing N points (where X[K], Y[K] are the coordinates of the K-th point), returns the number of diamonds on the plane.
For example, for N = 7 points whose coordinates are specified in arrays X = [1, 1, 2, 2, 2, 3, 3] and Y = [3, 4, 1, 3, 5, 3, 4], the function should return 2, since we can find two diamonds as shown in the picture below:
Given arrays: X = [1, 2, 3, 3, 2, 1], Y = [1, 1, 1, 2, 2, 2], the function should return 0, since there are no diamonds on the plane:
Write an efficient algorithm for the following assumptions:
- N is an integer within the range [4..1,500];
- each element of arrays X and Y is an integer within the range [0..N-1];
- given N points are pairwise distinct.
A diamond is a quadrilateral whose four sides all have the same length and whose diagonals are parallel to the coordinate axes.
You are given N distinct points on a plane. Count the number of different diamonds that can be constructed using these points as vertices (two diamonds are different if their sets of vertices are different). Do not count diamonds whose area is empty.
Write a function:
function solution($X, $Y);
that, given two arrays X and Y, each containing N integers, representing N points (where X[K], Y[K] are the coordinates of the K-th point), returns the number of diamonds on the plane.
For example, for N = 7 points whose coordinates are specified in arrays X = [1, 1, 2, 2, 2, 3, 3] and Y = [3, 4, 1, 3, 5, 3, 4], the function should return 2, since we can find two diamonds as shown in the picture below:
Given arrays: X = [1, 2, 3, 3, 2, 1], Y = [1, 1, 1, 2, 2, 2], the function should return 0, since there are no diamonds on the plane:
Write an efficient algorithm for the following assumptions:
- N is an integer within the range [4..1,500];
- each element of arrays X and Y is an integer within the range [0..N-1];
- given N points are pairwise distinct.
A diamond is a quadrilateral whose four sides all have the same length and whose diagonals are parallel to the coordinate axes.
You are given N distinct points on a plane. Count the number of different diamonds that can be constructed using these points as vertices (two diamonds are different if their sets of vertices are different). Do not count diamonds whose area is empty.
Write a function:
sub solution { my ($X, $Y) = @_; my @X = @$X; my @Y = @$Y; ... }
that, given two arrays X and Y, each containing N integers, representing N points (where X[K], Y[K] are the coordinates of the K-th point), returns the number of diamonds on the plane.
For example, for N = 7 points whose coordinates are specified in arrays X = [1, 1, 2, 2, 2, 3, 3] and Y = [3, 4, 1, 3, 5, 3, 4], the function should return 2, since we can find two diamonds as shown in the picture below:
Given arrays: X = [1, 2, 3, 3, 2, 1], Y = [1, 1, 1, 2, 2, 2], the function should return 0, since there are no diamonds on the plane:
Write an efficient algorithm for the following assumptions:
- N is an integer within the range [4..1,500];
- each element of arrays X and Y is an integer within the range [0..N-1];
- given N points are pairwise distinct.
A diamond is a quadrilateral whose four sides all have the same length and whose diagonals are parallel to the coordinate axes.
You are given N distinct points on a plane. Count the number of different diamonds that can be constructed using these points as vertices (two diamonds are different if their sets of vertices are different). Do not count diamonds whose area is empty.
Write a function:
def solution(X, Y)
that, given two arrays X and Y, each containing N integers, representing N points (where X[K], Y[K] are the coordinates of the K-th point), returns the number of diamonds on the plane.
For example, for N = 7 points whose coordinates are specified in arrays X = [1, 1, 2, 2, 2, 3, 3] and Y = [3, 4, 1, 3, 5, 3, 4], the function should return 2, since we can find two diamonds as shown in the picture below:
Given arrays: X = [1, 2, 3, 3, 2, 1], Y = [1, 1, 1, 2, 2, 2], the function should return 0, since there are no diamonds on the plane:
Write an efficient algorithm for the following assumptions:
- N is an integer within the range [4..1,500];
- each element of arrays X and Y is an integer within the range [0..N-1];
- given N points are pairwise distinct.
A diamond is a quadrilateral whose four sides all have the same length and whose diagonals are parallel to the coordinate axes.
You are given N distinct points on a plane. Count the number of different diamonds that can be constructed using these points as vertices (two diamonds are different if their sets of vertices are different). Do not count diamonds whose area is empty.
Write a function:
def solution(x, y)
that, given two arrays X and Y, each containing N integers, representing N points (where X[K], Y[K] are the coordinates of the K-th point), returns the number of diamonds on the plane.
For example, for N = 7 points whose coordinates are specified in arrays X = [1, 1, 2, 2, 2, 3, 3] and Y = [3, 4, 1, 3, 5, 3, 4], the function should return 2, since we can find two diamonds as shown in the picture below:
Given arrays: X = [1, 2, 3, 3, 2, 1], Y = [1, 1, 1, 2, 2, 2], the function should return 0, since there are no diamonds on the plane:
Write an efficient algorithm for the following assumptions:
- N is an integer within the range [4..1,500];
- each element of arrays X and Y is an integer within the range [0..N-1];
- given N points are pairwise distinct.
A diamond is a quadrilateral whose four sides all have the same length and whose diagonals are parallel to the coordinate axes.
You are given N distinct points on a plane. Count the number of different diamonds that can be constructed using these points as vertices (two diamonds are different if their sets of vertices are different). Do not count diamonds whose area is empty.
Write a function:
object Solution { def solution(x: Array[Int], y: Array[Int]): Int }
that, given two arrays X and Y, each containing N integers, representing N points (where X[K], Y[K] are the coordinates of the K-th point), returns the number of diamonds on the plane.
For example, for N = 7 points whose coordinates are specified in arrays X = [1, 1, 2, 2, 2, 3, 3] and Y = [3, 4, 1, 3, 5, 3, 4], the function should return 2, since we can find two diamonds as shown in the picture below:
Given arrays: X = [1, 2, 3, 3, 2, 1], Y = [1, 1, 1, 2, 2, 2], the function should return 0, since there are no diamonds on the plane:
Write an efficient algorithm for the following assumptions:
- N is an integer within the range [4..1,500];
- each element of arrays X and Y is an integer within the range [0..N-1];
- given N points are pairwise distinct.
A diamond is a quadrilateral whose four sides all have the same length and whose diagonals are parallel to the coordinate axes.
You are given N distinct points on a plane. Count the number of different diamonds that can be constructed using these points as vertices (two diamonds are different if their sets of vertices are different). Do not count diamonds whose area is empty.
Write a function:
public func solution(_ X : inout [Int], _ Y : inout [Int]) -> Int
that, given two arrays X and Y, each containing N integers, representing N points (where X[K], Y[K] are the coordinates of the K-th point), returns the number of diamonds on the plane.
For example, for N = 7 points whose coordinates are specified in arrays X = [1, 1, 2, 2, 2, 3, 3] and Y = [3, 4, 1, 3, 5, 3, 4], the function should return 2, since we can find two diamonds as shown in the picture below:
Given arrays: X = [1, 2, 3, 3, 2, 1], Y = [1, 1, 1, 2, 2, 2], the function should return 0, since there are no diamonds on the plane:
Write an efficient algorithm for the following assumptions:
- N is an integer within the range [4..1,500];
- each element of arrays X and Y is an integer within the range [0..N-1];
- given N points are pairwise distinct.
A diamond is a quadrilateral whose four sides all have the same length and whose diagonals are parallel to the coordinate axes.
You are given N distinct points on a plane. Count the number of different diamonds that can be constructed using these points as vertices (two diamonds are different if their sets of vertices are different). Do not count diamonds whose area is empty.
Write a function:
function solution(X: number[], Y: number[]): number;
that, given two arrays X and Y, each containing N integers, representing N points (where X[K], Y[K] are the coordinates of the K-th point), returns the number of diamonds on the plane.
For example, for N = 7 points whose coordinates are specified in arrays X = [1, 1, 2, 2, 2, 3, 3] and Y = [3, 4, 1, 3, 5, 3, 4], the function should return 2, since we can find two diamonds as shown in the picture below:
Given arrays: X = [1, 2, 3, 3, 2, 1], Y = [1, 1, 1, 2, 2, 2], the function should return 0, since there are no diamonds on the plane:
Write an efficient algorithm for the following assumptions:
- N is an integer within the range [4..1,500];
- each element of arrays X and Y is an integer within the range [0..N-1];
- given N points are pairwise distinct.
A diamond is a quadrilateral whose four sides all have the same length and whose diagonals are parallel to the coordinate axes.
You are given N distinct points on a plane. Count the number of different diamonds that can be constructed using these points as vertices (two diamonds are different if their sets of vertices are different). Do not count diamonds whose area is empty.
Write a function:
Private Function solution(X As Integer(), Y As Integer()) As Integer
that, given two arrays X and Y, each containing N integers, representing N points (where X[K], Y[K] are the coordinates of the K-th point), returns the number of diamonds on the plane.
For example, for N = 7 points whose coordinates are specified in arrays X = [1, 1, 2, 2, 2, 3, 3] and Y = [3, 4, 1, 3, 5, 3, 4], the function should return 2, since we can find two diamonds as shown in the picture below:
Given arrays: X = [1, 2, 3, 3, 2, 1], Y = [1, 1, 1, 2, 2, 2], the function should return 0, since there are no diamonds on the plane:
Write an efficient algorithm for the following assumptions:
- N is an integer within the range [4..1,500];
- each element of arrays X and Y is an integer within the range [0..N-1];
- given N points are pairwise distinct.