목록전체 글 (711)
Software
4. Foreach C++ 03 #include #include using namespace std; int main() { vector v; v.push_back(1); v.push_back(2); v.push_back(3); for (vector::iterator itr = v.begin(); itr != v.end(); itr++) { cout
Goals of C++ 11 Maintain stability and compatibility with C++ 98 and possibly with C Prefer introducing new features via the standard library, rather than extending the core language Prefer changes that can evolve programming technique Improve C++ to facilitate systems and library design, rather than introduce new features useful only to specific applications Increase type safety by providing sa..
https://leetcode.com/problems/number-of-zero-filled-subarrays/ Number of Zero-Filled Subarrays - LeetCode Can you solve this real interview question? Number of Zero-Filled Subarrays - Given an integer array nums, return the number of subarrays filled with 0. A subarray is a contiguous non-empty sequence of elements within an array. Example 1: Input: nums = leetcode.com const zeroFilledSubarray =..
https://school.programmers.co.kr/learn/courses/30/lessons/161989 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 문제를 단순하게 접근하면 된다. section에 있는 범위만 덧칠하면 되기 때문에 greedy하게 접근한다. 우선 start 변수를 선언하여 section의 마지막 원소를 가져온다. 한번 덧칠하는 단계이기 때문에 answer = 1이며, 이 start에서 m 만큼 이동한다. while문으로 section을 비울 때까지 반복 현재 위치를 section.pop()을 이용해 가져오며, 만약 curre..
https://leetcode.com/problems/capacity-to-ship-packages-within-d-days/description/ Capacity To Ship Packages Within D Days - LeetCode Can you solve this real interview question? Capacity To Ship Packages Within D Days - A conveyor belt has packages that must be shipped from one port to another within days days. The ith package on the conveyor belt has a weight of weights[i]. Each day, we leetcod..
https://school.programmers.co.kr/learn/courses/30/lessons/150369 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr greedy 알고리즘으로 접근. 택배 배달과 수거를 앞에서가 아닌 뒤에서부터 진행을 하면 된다. deveriesIndex와 pickupsIndex를 선언하여 n - 1로 저장하고, 이 두 변수를 이용해서 더 큰 값이 사실상 출발 위치가 된다. while문을 이용해 두 인덱스가 모든 배열을 순회한 -1 값이 될 때까지 반복한다. (뒤에서부터 순회했기 때문에 n - 1 ~ 0 으로 간다.) deli..
https://school.programmers.co.kr/learn/courses/30/lessons/150368 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr DFS를 이용한 문제 풀이. 우선 answer에 -Infinity 2개를 넣어주어서 최대값 갱신을 할 수 있도록 한다. 이모티콘 할인율은 10, 20, 30, 40 4개가 있으므로 discounts 배열에 저장. users와 emoticons의 길이를 나타내는 변수 usersLength, emoticonsLength. 각 유저가 이모티콘을 구매했을 때의 비용을 나타내는 userCost를 선언한다..
https://school.programmers.co.kr/learn/courses/30/lessons/92345?language=javascript 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr DFS를 이용해 시뮬레이션을 풀었다. dfs에 전달하는 것은 현재 플레이어의 x, y 좌표, 다음 플레이어의 x, y 좌표다. 우선 return할 변수 result를 선언하여 [false, 0]으로 저장한다. result는 [진행 여부, 움직인 횟수]를 뜻한다. 우선 인자로 받아온 좌표(ax, ay)가 상하좌우로 움직일 수 있는지 판단한다. 만약 4방향 모두 움..