Circle and Lattice Points
Easy Accuracy: 17.31% Submissions: 133 Points: 2

Given an integer R which represents the radius of a circle that has (0,0) as its centre, find the total number of lattice points on the circumference. Lattice Points are points with coordinates as integers in 2-D space.

Example 1:

Input: R = 5
Output: 12
Explanation: (0,5), (0,-5), (5,0), 
(-5,0), (3,4), (-3,4), (-3,-4), (3,-4), 
(4,3), (-4,3), (-4,-3), (4,-3).

Example 2:

Input: R = 88
Output: 4
Explanation: (0,88), (88,0), (0,-88), 

Your Task:  
You don't need to read input or print anything. Your task is to complete the function latticePoints() which takes R as input and returns the number of lattice points.

Expected Time Complexity: O(RsqrtR)
Expected Auxiliary Space: O(1)

0 ≤ R ≤ 104

to report an issue on this page.


We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?


All Submissions

My Submissions:

Login to access your submissions.

Output Window