https://school.programmers.co.kr/learn/courses/30/lessons/92335?itm_content=course14743 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr class Solution { public boolean sosu(long x) { if (x
2배가 된다는 걸 이용해서 풀었다... https://school.programmers.co.kr/learn/courses/30/lessons/12980 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr dfs버젼으로도 풀었는데, 그건 숫자가 커지면 개노가다라 시간이 진짜!!!오래걸려서 타임아웃됨... public class Solution { public int solution(int n) { int ans = 0; while(n>0) { int temp=n/2; ans+=n-temp*2; n=temp; } return ans; } }
https://school.programmers.co.kr/learn/courses/30/lessons/43165 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr dfs를 사용해서 풀었다! class Solution { int answer = 0; public void dfsSol(int[] numbers, int index, int target, int now){ if (index>=numbers.length) { if (target==now) answer++; return; //문장의 끝이라면! } dfsSol(numbers, index+1, targe..
https://school.programmers.co.kr/learn/courses/30/lessons/12985 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr n은 안 줘도 될것같은데 왜 준지 모르겠다...? class Solution { public int solution(int n, int a, int b) { int answer = 0; while(a!=b){ answer++; a=++a/2; b=++b/2; } return answer; } } ++한 값을 /2하는 이유는 1과 2를 나누면 각각 0,1이 되어서!
https://school.programmers.co.kr/learn/courses/30/lessons/42885 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr import java.util.*; class Solution { public int solution(int[] people, int limit) { int answer = 0; //한 번에 최대 2명!! //크기 순으로(큰거~작은거) Arrays.sort(people); Deque deque = new ArrayDeque(); for(int i=0;i
https://school.programmers.co.kr/learn/courses/30/lessons/42842 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr class Solution { public int[] solution(int brown, int yellow) { //가로>=세로 길이 고정!!! int[] answer = new int[2]; //가로, 세로 int s=brown+ yellow;//전체 넓이, 즉 a*b int k=(int)Math.floor(Math.sqrt(s)); //2a+2b-4 = brown int a=s,b; whil..
https://school.programmers.co.kr/learn/courses/30/lessons/70129 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr class Solution { public int[] solution(String s) { int[] answer = new int[2]; //이진변환수, 제거된 0 수 while(!s.equals("1")) { answer[0]++; int temp=s.replaceAll("0", "").length(); answer[1]+=s.length()-temp; s=Integer.toString(tem..
https://school.programmers.co.kr/learn/courses/30/lessons/12922 사실상 푸는 의미가 거의 없는 문제긴 함.... class Solution { public String solution(int n) { String answer = ""; for(int i=1;i
https://school.programmers.co.kr/learn/courses/30/lessons/42576?language=java 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr import java.util.Arrays; class Solution { public String solution(String[] participant, String[] completion) { Arrays.sort(participant); Arrays.sort(completion); for(int i=0;i