Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 6792618

Browse files
Create Find the Number of Ways to Place People I.java
1 parent 84d720f commit 6792618

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
class Solution {
2+
public int numberOfPairs(int[][] points) {
3+
Arrays.sort(points, (o1, o2) -> {
4+
if(o1[0] != o2[0]) {
5+
return o2[0] - o1[0];
6+
}
7+
return o1[1] - o2[1];
8+
});
9+
int n = points.length;
10+
int result = 0;
11+
for (int i = 0; i < n - 1; i++) {
12+
int curr = Integer.MAX_VALUE;
13+
for (int j = i + 1; j < n; j++) {
14+
if (points[j][1] >= points[i][1] && curr > points[j][1]) {
15+
result++;
16+
curr = points[j][1];
17+
}
18+
}
19+
}
20+
return result;
21+
}
22+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /