Count Lattice Points Inside a Circle LeetCode solution in Java
1class Solution {2public int countLatticePoints(int[][] circles) {3Set<String> answer = new HashSet<String>();45for (int[] c : circles) {6int x = c[0], y = c[1], r = c[2];78// traversing over all the points that lie inside the smallest square capable of containing9// the whole circle10for (int xx = x - r; xx <= x + r; xx++)11for (int yy = y - r; yy <= y + r; yy++)12if ((r * r) >= ((x - xx) * (x - xx)) + ((y - yy) * (y - yy))) answer.add(xx + ":" + yy);13}1415return answer.size();16}17}