We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 0f62b91 + 5ab3460 commit 54fd787Copy full SHA for 54fd787
0224LJH/202510/22 PGM 구명보트.md
@@ -0,0 +1,32 @@
1
+```java
2
+import java.io.*;
3
+import java.util.*;
4
+
5
+class Solution {
6
+ public int solution(int[] people, int limit) {
7
8
+ Arrays.sort(people);
9
+ System.out.println(people);
10
+ int front = 0;
11
+ int answer = 0;
12
+ int back = people.length-1;
13
14
+ while (front < back){
15
+ if (people[front]+people[back] <= limit){
16
+ answer++;
17
+ people[front++] = 0;
18
+ people[back--] = 0;
19
20
21
+ } else{
22
+ back--;
23
+ }
24
25
26
+ for (int n: people){
27
+ if (n != 0) answer++;
28
29
30
+ return answer;
31
32
+}```
0 commit comments