leetcode.com/problems/employee-importance/ Employee Importance - 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 직원의 ID, 중요도, 직속부하직원의 ID가 포함된 직원 정보의 데이터구조가 정의된다. 어떤 직원의 중요도는 해당 직원의 중요도와 직속부하직원의 중요도의 합이다. 직원객체의 배열과, 직원ID를 argument로 넘겨주면 해당 직원의 중요도를 return 하도록 하는 문제이다., 아래와 같이 코드를 작성..
leetcode.com/problems/n-repeated-element-in-size-2n-array/ N-Repeated Element in Size 2N Array - 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 배열을 argument로 넘겨준다. 해당 배열 내 반복되는 숫자가 있다. 그 외의 숫자는 unique 값이다. 반복되는 숫자를 return class Solution { public: int repeatedNTimes(vector& A) { in..
leetcode.com/problems/sum-of-unique-elements/ Sum of Unique Elements - 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 배열을 argument로 넘겨주면 배열 내 unique value를 찾아서 그 값들의 합을 구하는 문제이다 class Solution { public: int sumOfUnique(vector& nums) { bool flag = false; int cnt = 0; for (int i = 0..
leetcode.com/problems/how-many-numbers-are-smaller-than-the-current-number/ How Many Numbers Are Smaller Than the Current 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 배열을 argument로 넘겨주면 해당 배열의 각 원소별로 배열 내 해당 원소보다 작은 원소가 있다면 count하여 각 count한 결과를 배열로 만들어서 return해주는 문제임. c..
leetcode.com/problems/jewels-and-stones/ Jewels and Stones - 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 argument로 2개의 string을 input 함수는 2개의 string을 parameter로 받아와서, 첫번째 문자열의 원소별로 두번째 문자열의 원소와 같은것이 몇개 있는지를 return함. 2중 for문 class Solution { public: int numJewelsInStones(string j..
leetcode.com/problems/number-of-good-pairs/ Number of Good Pairs - 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 Given an array of integers nums. A pair (i,j) is called good if nums[i] == nums[j] and i
programmers.co.kr/learn/courses/30/lessons/42883 코딩테스트 연습 - 큰 수 만들기 programmers.co.kr #include #include #include using namespace std; priority_queue total; vector temp; string ExtractString(string object, vector position) { if (object.size() < position.size()) return ""; int cnt = 0; string tmp; for (int n = 0; n < object.size(); n++) { if (cnt < position.size()) { if (n == position[cnt]) { cnt+..
programmers.co.kr/learn/courses/30/lessons/42748 코딩테스트 연습 - K번째수 [1, 5, 2, 6, 3, 7, 4] [[2, 5, 3], [4, 4, 1], [1, 7, 3]] [5, 6, 3] programmers.co.kr #include #include using namespace std; vector solution(vector array, vector commands) { vector tmp; vector answer; int data; for (int i = 0; i < commands.size(); i++) { for (int j = commands[i][0] - 1; j