본문 바로가기

알고리즘/알고리즘54

[C++] 프로그래머스 : 파괴되지않은 건물 https://school.programmers.co.kr/learn/courses/30/lessons/92344 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 누적합을 통해 효율성 확보 https://tech.kakao.com/2022/01/14/2022-kakao-recruitment-round-1/#%EB%AC%B8%EC%A0%9C-6-%ED%8C%8C%EA%B4%B4%EB%90%98%EC%A7%80-%EC%95%8A%EC%9D%80-%EA%B1%B4%EB%AC%BC 2022 카카오 신입 공채 1차 온라인 코딩테스트 for Tech developer.. 2022. 11. 1.
[C++] 프로그래머스 : 등산코스 정하기 https://school.programmers.co.kr/learn/courses/30/lessons/118669 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 다익스트라 알고리즘 적용 & 다른 기준으로 비교 #include #include #include #include using namespace std; struct cmp{ bool operator()(pair a, pair b){ return a.second > b.second; } }; vector solution(int n, vector paths, vector gates, vector su.. 2022. 11. 1.
[C++] 프로그래머스 : 할인 행사 https://school.programmers.co.kr/learn/courses/30/lessons/131127 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr map 사용해서 비교하는 문제 비교 구현 방식을 수정하면서 코드를 더 정제화할 수 있었다 1. map 2개 사용, map iterator 포인터 사용 #include #include #include using namespace std; int solution(vector want, vector number, vector discount) { int answer = 0; map wm, sm; fo.. 2022. 10. 30.
[C++] 프로그래머스 : 롤케이크 자르기 https://school.programmers.co.kr/learn/courses/30/lessons/132265 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr set + 단순반복 = 시간초과 map + 조각넘기기방식 적용으로 해결 #include #include #include using namespace std; int solution(vector topping) { int answer = 0; int tSize = topping.size(); map c1, c2; // topping type, count // 안자른상태 for(int i=0; is.. 2022. 10. 29.
[C++] 프로그래머스 : 야간 전술보행 https://school.programmers.co.kr/learn/courses/30/lessons/133501?language=cpp 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 결국 화랑이 붙잡히는 경우는, "t시간에 distance=t에서 근무하는 경비병이 있을 때"인 것을 파악하는것 #include #include using namespace std; int solution(int distance, vector scope, vector times) { int answer = distance; for(int i=0; i 2022. 10. 29.
[JAVA] 프로그래머스 : 뉴스 클러스터링 https://school.programmers.co.kr/learn/courses/30/lessons/17677 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 1. Map.Entry, 정규식 이용 import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; class Solution { public int solution(String str1, String str2) { int answer = 0; HashMap m1 = new HashMap(); HashMap m2 = new .. 2022. 8. 5.
[JAVA] 프로그래머스 : 행렬 테두리 회전하기 https://school.programmers.co.kr/learn/courses/30/lessons/77485 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 1. 단순 시뮬레이션 문제 class Solution { public int[] solution(int rows, int columns, int[][] queries) { int q = queries.length; int[] answer = new int[q]; int[][] arr = new int[rows][columns]; for(int i=0; i x1y1 for(int j=y2; j>y1.. 2022. 8. 2.
[JAVA] 프로그래머스 : 신규 아이디 추천 https://school.programmers.co.kr/learn/courses/30/lessons/72410 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 1. JAVA의 문자열 String, Array, StringBuilder 객체와 함수들을 연습해볼 수 있는 문제 + 정규표현식까지 2. 정규표현식 사용하지 않은 코드 class Solution { public String makeA(String a){ if(a.length() == 0) return "a"; else return a; } public String solution(String ne.. 2022. 8. 1.
[JAVA] 프로그래머스 : 로또의 최고 순위와 최저 순위 https://school.programmers.co.kr/learn/courses/30/lessons/77484 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 1. 첫코드 & 개선가능점 import java.util.HashMap; class Solution { public int[] solution(int[] lottos, int[] win_nums) { int[] answer = new int[2]; HashMap map = new HashMap(); for(int l : lottos){ if(map.containsKey(l)){ // lottos에.. 2022. 8. 1.