Company: American_Express
Difficulty: medium
Max Points in a Rectangle Problem Description There are N points on a plane and an integer perimeter . Your task is to choose the lengths of sides of a rectangle and place the rectangle on a plane so that it covers the maximum number of points. Points lying on the sides of the rectangle are considered to be covered by it. Sides of the rectangle should be parallel to the coordinate's system axis and sum of their lengths should be equal to perimeter . For example, for perimeter = 10 , the possible rectangle sides are: 1x4, 2x3, 3x2 and 4x1. What is the maximum number of points that can be covered by the rectangle? Assume that the following declarations are given: struct Point2D { int x; int y; }; Write a function: int solution(std::vector<Point2D> &points, int perimeter); that, given an array points made of N objects of type Point2D and an integer perimeter , returns the maximum number of points which can be covered by the rectangle. Examples Example 1: Input: points = [(1, 1),