Please enter your email address or userHandle.
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.
Input: R = 5
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).
Input: R = 88
Explanation: (0,88), (88,0), (0,-88),
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
We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?
Login to access your submissions.
Please choose 'ReadOnlyMode' if you needn't to 'Edit' the problem e.g. viewing OJ's solution, TestCase Files (TCFs), TimeLimit etc.