Company: American_Express
Difficulty: medium
Max Points in a Rectangle Problem Description You are given N points scattered on a plane, along with an integer perimeter . Choose the side lengths of a rectangle and position that rectangle on the plane so that it encloses as many of the points as possible. A point lying exactly on one of the rectangle's edges counts as enclosed. The rectangle's sides must run parallel to the coordinate axes, and the two side lengths must add up (twice, as usual for a perimeter) to perimeter . For instance, with perimeter = 10 , the achievable side pairs are 1x4, 2x3, 3x2, and 4x1. What is the largest number of points such a rectangle can enclose? 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: Inp