Skip to content

Commit 3227b5a

Browse files
authored
feat: add java solution to lc problem No:2249 (doocs#803)
No.2249.Count Lattice Points Inside a Circle
1 parent f52db36 commit 3227b5a

File tree

3 files changed

+51
-2
lines changed

3 files changed

+51
-2
lines changed

solution/2200-2299/2249.Count Lattice Points Inside a Circle/README.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,23 @@
7373
<!-- 这里可写当前语言的特殊实现逻辑 -->
7474

7575
```java
76-
76+
class Solution {
77+
public int countLatticePoints(int[][] circles) {
78+
int ans = 0;
79+
for (int i = 0; i <= 200; i++) {
80+
for (int j = 0; j <= 200; j++) {
81+
for (int[] circle : circles) {
82+
int x = circle[0], y = circle[1], r = circle[2];
83+
if ((i - x) * (i - x) + (j - y) * (j - y) <= r * r) {
84+
ans++;
85+
break;
86+
}
87+
}
88+
}
89+
}
90+
return ans;
91+
}
92+
}
7793
```
7894

7995
### **TypeScript**

solution/2200-2299/2249.Count Lattice Points Inside a Circle/README_EN.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,23 @@ Some of them are (0, 2), (2, 0), (2, 4), (3, 2), and (4, 4).
5959
### **Java**
6060

6161
```java
62-
62+
class Solution {
63+
public int countLatticePoints(int[][] circles) {
64+
int ans = 0;
65+
for (int i = 0; i <= 200; i++) {
66+
for (int j = 0; j <= 200; j++) {
67+
for (int[] circle : circles) {
68+
int x = circle[0], y = circle[1], r = circle[2];
69+
if ((i - x) * (i - x) + (j - y) * (j - y) <= r * r) {
70+
ans++;
71+
break;
72+
}
73+
}
74+
}
75+
}
76+
return ans;
77+
}
78+
}
6379
```
6480

6581
### **TypeScript**
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
class Solution {
2+
public int countLatticePoints(int[][] circles) {
3+
int ans = 0;
4+
for (int i = 0; i <= 200; i++) {
5+
for (int j = 0; j <= 200; j++) {
6+
for (int[] circle : circles) {
7+
int x = circle[0], y = circle[1], r = circle[2];
8+
if ((i - x) * (i - x) + (j - y) * (j - y) <= r * r) {
9+
ans++;
10+
break;
11+
}
12+
}
13+
}
14+
}
15+
return ans;
16+
}
17+
}

0 commit comments

Comments
 (0)