IT/알고리즘87 3] Leetcode 1431. Kids With the Greatest Number of Candies candies 배열과 extra 숫자가 주어질 때 배열의 각 숫자들이 extra 값을 더했을 때 배열에서 가장 큰 값이 될 수 있으면 true, 아니면 false를 반환하는 문제. 배열에서 최댓값 구하고 처음부터 돌면서 extra 더했을 때 최댓값과 비교한다. class Solution { public: vector kidsWithCandies(vector& candies, int extraCandies) { vector ans; int maxNum = 0; for(int i = 0;i maxNum) maxNum = candies[i]; for(int i = 0;i= maxNum) ans.push_back(true); else ans.push_back(false); return ans; } }; 2020. 6. 18. 2] Leetcode 1470. Shuffle the Array Shuffle the 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 배열 안에 짝수개의 숫자들이 있고 그걸 반으로 나눠서 기준에 맞게 다시 정렬하는 문제다. class Solution { public: vector shuffle(vector& nums, int n) { vectorans; for(int i=0;i 2020. 6. 16. 1] Leetcode 1480. Running Sum of 1d Array Running Sum of 1d 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 처음은 그대로 해주고 다음 값부터는 앞에 값 더 해주면 된다. class Solution { public: vector runningSum(vector& nums) { for(int i=1;i 2020. 6. 16. 이전 1 ··· 19 20 21 22 다음