자바/프로그래머스(36)
-
[Programmers/JAVA] H-Index
내 코드 class Solution { public int solution(int[] citations) { int answer = 0; for(int i=citations.length; i>0; i--) { int count=0; int n_count=0; for(int x : citations) { if(i=i && n_count
2022.12.30 -
[Programmers/JAVA] 멀리 뛰기
내 코드 class Solution { public long solution(int n) { long answer = 0; int n_1=1, n_2=0; int sum=0; for(int i=0; i
2022.12.30 -
[Programmers/JAVA] 점프와 순간 이동
내 코드 import java.util.*; public class Solution { public int solution(int n) { int ans = 0; while(n!=0) { ans+=n%2; n=n/2; } return ans; } } 느낀점 첨에 어려운듯??하다가 문제를 정확히 이해한 후에는 쉬워졌다!! 다행... 쉽게 풀리는 문제라...ㅎㅎ
2022.12.28 -
[Programmers/JAVA] 예상 대진표
내 코드 class Solution { public int solution(int n, int a, int b) { int answer = 0; while(n/2 != 0) { answer++; if(a/2 != b/2) { if(Math.abs(a-b)==1) { break; } } if(a%2!=0) { a=a/2+1; }else { a=a/2; } if(b%2!=0) { b=b/2+1; }else { b=b/2; } n=n/2; } return answer; } } 느낀점 역시 코딩은 계속 꾸준히해야 머리가 돌아가나보다.. 연말에 코로나까지 겹쳐서 바쁘게 사느라 며칠 못했더니 머리가 안돌아간다..
2022.12.28 -
[Programmers/JAVA] N개의 최소공배수
내 코드 class Solution { public int solution(int[] arr) { int answer = 0; int max_gop=0; int i=1; while(true) { max_gop=arr[arr.length-1]*i; int result=0; for(int j=0; j
2022.12.07 -
[Programmers/JAVA] 구명보트
내 코드 import java.util.*; class Solution { public int solution(int[] people, int limit) { int answer=0; Arrays.sort(people); ArrayList list=new ArrayList(); for(int p : people) { list.add(p); } while(!list.isEmpty()) { int max=list.remove(list.size()-1); if(list.size()>=1 && max+list.get(0)
2022.12.05