본문 바로가기

PS

(112)
프로그래머스 [PCCE 기출문제] 1번 / 출력 문제 주어진 초기 코드는 변수에 데이터를 저장하고 출력하는 코드입니다. 아래와 같이 출력되도록 빈칸을 채워 코드를 완성해 주세요. Spring is beginning 13 310 의도한 풀이는 이것일 것이다. #include using namespace std; int main(void) { string msg = "Spring is beginning"; int val1 = 3; string val2 = "3"; cout
프로그래머스 코딩전문역량인증시험 PCCP 후기 원래 응시료는 4만원이지만, 학교에서 운영하는 지자체-대학 협력 사업에 참여하여 무료로 참여할 수 있었다. 파이썬, 자바, 자바스크립트, C++ 중 언어를 선택하여 응시할 수 있는데, 익숙한 C++를 선택했다. 총 2시간동안 휴대폰으로 옆모습이 나오게 촬영을 하면서 시험 문제를 풀어야하는데, 셀카봉이 없으면 휴대폰 각도를 잡기 어려웠을 것 같다. 빈 A4 용지 한 장은 필기용으로 사용이 가능하지만, 집에 A4 용지가 없어서 그냥 쳤다. 총 4문제가 나왔는데, 완전탐색, 백트래킹, 누적합, 해시셋, 재귀 등 기본적인 알고리즘 문제가 나왔고 특별한 지식을 요구하는 문제는 없었다. 결과는 만점이었다. 시간에 쫓겨서 문제를 풀다보니 잘 쳤다는 느낌은 받지 못하였는데 운이 좋게도 좋은 점수가 나왔다.
[C++] LeetCode (릿코드) 977 : Squares of a Sorted Array 문제 Loading... (leetcode.com) Squares of a Sorted Array - LeetCode Can you solve this real interview question? Squares of a Sorted Array - Given an integer array nums sorted in non-decreasing order, return an array of the squares of each number sorted in non-decreasing order. Example 1: Input: nums = [-4,-1,0,3,10] Out leetcode.com 코드 class Solution { public: vector sortedSquares(vector &nums) { ..
[C++] LeetCode (릿코드) 35 : Search Insert Position 문제 Loading Question... - LeetCode Search Insert Position - LeetCode Can you solve this real interview question? Search Insert Position - Given a sorted array of distinct integers and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order. You must w leetcode.com 코드 class Solution { public: int searchInsert(vector &nums, in..
[C++] LeetCode (릿코드) 278 : First Bad Version 문제 First Bad Version - LeetCode First Bad Version - LeetCode Can you solve this real interview question? First Bad Version - You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality check. Since each version is developed base leetcode.com 코드 class Solution { public: int search(vector &nums, int target) { ..
[C++] LeetCode (릿코드) 704 : Binary Search 문제 Binary Search - LeetCode Binary Search - LeetCode Can you solve this real interview question? Binary Search - Given an array of integers nums which is sorted in ascending order, and an integer target, write a function to search target in nums. If target exists, then return its index. Otherwise, return -1. leetcode.com 코드 class Solution { public: int search(vector &nums, int target) { int lo =..
[C++] BOJ (백준) 1074 : Z 문제 1074번: Z (acmicpc.net) 1074번: Z 한수는 크기가 2N × 2N인 2차원 배열을 Z모양으로 탐색하려고 한다. 예를 들어, 2×2배열을 왼쪽 위칸, 오른쪽 위칸, 왼쪽 아래칸, 오른쪽 아래칸 순서대로 방문하면 Z모양이다. N > 1인 경우, 배열을 www.acmicpc.net 코드 #include using namespace std; int n, r, c; void input() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cin >> n >> r >> c; } void solve(int y, int x, int size, int cnt) { if (size == 0) { cout = x + d) { x += d; cnt += ..
[C++] BOJ (백준) 1012 : 유기농 배추 문제 1012번: 유기농 배추 (acmicpc.net) 1012번: 유기농 배추 차세대 영농인 한나는 강원도 고랭지에서 유기농 배추를 재배하기로 하였다. 농약을 쓰지 않고 배추를 재배하려면 배추를 해충으로부터 보호하는 것이 중요하기 때문에, 한나는 해충 방지에 www.acmicpc.net 코드 1 (DFS) #include #include #define CABBAGE 1 using namespace std; int m, n, k; int dx[4] = {-1, 1, 0, 0}; int dy[4] = {0, 0, -1, 1}; vector map; vector isProtected; vector cabbage; void input() { cin >> m >> n >> k; map = vector(m, ve..