분류 전체보기
-
코딩테스트 연습 > 해시 > 위장프로그래머스(Programmers) 2020. 2. 6. 16:32
https://programmers.co.kr/learn/courses/30/lessons/42578 코딩테스트 연습 - 위장 | 프로그래머스 programmers.co.kr 키워드 - 구현, 해시 Source #include #include #include #include using namespace std; int solution(vector clothes) { int answer = 1; map mm; vector arr; for(int i=0; i
-
완전탐색 > 모의고사프로그래머스(Programmers) 2020. 2. 6. 16:30
https://programmers.co.kr/learn/courses/30/lessons/42840 코딩테스트 연습 - 모의고사 | 프로그래머스 수포자는 수학을 포기한 사람의 준말입니다. 수포자 삼인방은 모의고사에 수학 문제를 전부 찍으려 합니다. 수포자는 1번 문제부터 마지막 문제까지 다음과 같이 찍습니다. 1번 수포자가 찍는 방식: 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, ... 2번 수포자가 찍는 방식: 2, 1, 2, 3, 2, 4, 2, 5, 2, 1, 2, 3, 2, 4, 2, 5, ... 3번 수포자가 찍는 방식: 3, 3, 1, 1, 2, 2, 4, 4, 5, 5, 3, programmers.co.kr 키워드 - 구현, 완전탐색 Source #include #include #..
-
2017 팁스타운 > 짝지어 제거하기프로그래머스(Programmers) 2020. 2. 6. 16:25
https://programmers.co.kr/learn/courses/30/lessons/12973 코딩테스트 연습 - 짝지어 제거하기 | 프로그래머스 짝지어 제거하기는, 알파벳 소문자로 이루어진 문자열을 가지고 시작합니다. 먼저 문자열에서 같은 알파벳이 2개 붙어 있는 짝을 찾습니다. 그다음, 그 둘을 제거한 뒤, 앞뒤로 문자열을 이어 붙입니다. 이 과정을 반복해서 문자열을 모두 제거한다면 짝지어 제거하기가 종료됩니다. 문자열 S가 주어졌을 때, 짝지어 제거하기를 성공적으로 수행할 수 있는지 반환하는 함수를 완성해 주세요. 성공적으로 수행할 수 있으면 1을, 아닐 경우 0을 리턴해주면 됩니다. 예를 들 programmers.co.kr 1. 문제 짝지어 제거하기는, 알파벳 소문자로 이루어진 문자열을 가..
-
171. Excel Sheet Column Number릿코드(LEETCODE) 2020. 2. 6. 16:15
https://leetcode.com/problems/excel-sheet-column-number/ Excel Sheet Column Number - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com class Solution { public: int titleToNumber(string s) { reverse(s.begin(), s.end()); const int size = s.size(); long long sol = s[0] - 'A'+ 1; for (in..
-
168. Excel Sheet Column Title릿코드(LEETCODE) 2020. 2. 6. 16:14
https://leetcode.com/problems/excel-sheet-column-title/ Excel Sheet Column Title - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com class Solution { public: string convertToTitle(int n) { string s; while (n) { s.push_back('A' + (n - 1) % 26); n = (n - 1) / 26; } reverse(s.begin(), s..
-
완전탐색 > 소수 찾기프로그래머스(Programmers) 2020. 2. 5. 15:21
https://programmers.co.kr/learn/courses/30/lessons/42839 코딩테스트 연습 - 소수 찾기 | 프로그래머스 한자리 숫자가 적힌 종이 조각이 흩어져있습니다. 흩어진 종이 조각을 붙여 소수를 몇 개 만들 수 있는지 알아내려 합니다. 각 종이 조각에 적힌 숫자가 적힌 문자열 numbers가 주어졌을 때, 종이 조각으로 만들 수 있는 소수가 몇 개인지 return 하도록 solution 함수를 완성해주세요. 제한사항 numbers는 길이 1 이상 7 이하인 문자열입니다. numbers는 0~9까지 숫자만으로 이루어져 있습니다. 013은 0, 1, 3 숫자가 적힌 종이 programmers.co.kr 에라토스테네스의 체를 사용하던지 속도가 느리다면 메모제이션이나 DP를 사..
-
581. Shortest Unsorted Continuous Subarray릿코드(LEETCODE) 2020. 2. 5. 15:13
https://leetcode.com/problems/shortest-unsorted-continuous-subarray/ Shortest Unsorted Continuous Subarray - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 문제 이해 입력으로 들어오는 배열에서 정렬되지 않은 구간을 찾는 문제 문제 접근 vector array를 하나를 추가 선언하고 정렬을 한다. 입력으로 들어온 nums array와 0부터 값이 다른 위치를 찾는다. 입력으로 들..
-
709. To Lower Case릿코드(LEETCODE) 2020. 2. 3. 19:02
https://leetcode.com/problems/to-lower-case/ To Lower Case - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 주어진 문자열을 소문자로 취환 하는 문제 아스키 코드값을 이용하여 풀이 class Solution { public: string toLowerCase(string str) { for(int i=0;i= 65 && str.at(i)