Skip to content

Commit

Permalink
Add #6 구명보트 - 박지원
Browse files Browse the repository at this point in the history
  • Loading branch information
since1909 committed Nov 30, 2024
1 parent 3c9ffe6 commit d459e8c
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions greedy/구명보트/박지원.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import java.util.*;
class Solution {
public int solution(int[] people, int limit) {
int answer = 0;
Arrays.sort(people);

int min = 0;
int max = people.length -1;

while(min <= max) {
if(people[min] + people[max] <= limit) {
min++;
}
max--;
answer++;
}
return answer;
}
}

0 comments on commit d459e8c

Please sign in to comment.