Create A Point

Given two integers, x and y, representing the coordinates of a point.

Your task is to create and return a Point structure containing the given coordinates.

The Point structure contains two integer fields:

  • x: Represents the x-coordinate of the point.
  • y: Represents the y-coordinate of the point.

Note: Store the given values in their corresponding fields without changing their order or signs.

Example 1:

Input: x = 3, y = 5

Output: [3, 5]

Explanation: The first input is 3, so the returned point's x coordinate is 3. The second input is 5, so its y coordinate is 5. Therefore, the returned point is displayed as [3, 5].

Example 2:

Input: x = -4, y = 7

Output: [-4, 7]

Explanation: The returned point stores -4 in its x member and 7 in its y member. The negative sign on -4 is preserved; the coordinates are neither swapped nor modified. Therefore, the result is [-4, 7].

Now Your Turn!

Pick the correct output for the given input

Input: x = 0, y = 0

Still unsure what the problem is asking ?

Let’s go through a few more examples, step by step, to make it clearer.

Constraints:

  • -109 <= x, y <= 109

Hints

Frequently Occurring Doubts

Interview Follow-up Questions

0
/**
* Definition for a point.
* struct Point {
* int x;
* int y;
* };
*/
 
 
class Solution {
public:
Point createPoint(int x, int y) {
// Write your code here
}
};
 
Test Case

Input:

X
Y