본문 바로가기

leetcode48

36] Leetcode 1460. Make Two Arrays Equal by Reversing Sub-arrays https://leetcode.com/problems/make-two-arrays-equal-by-reversing-sub-arrays/ Make Two Arrays Equal by Reversing Sub-arrays - 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 두 배열을 구성하는 숫자가 다르면 무조건 false 숫자 개수가 다르거나, 없는 숫자가 있거나.. class Solution { public: bool canBeEqual(vector& targe.. 2020. 7. 21.
33] Leetcode 1304. Find N Unique Integers Sum up to Zero Find N Unique Integers Sum up to Zero - 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 sumZero(int n) { vectorans; if(n%2 == 0){ for(int i = 1;i 2020. 7. 15.
32] Leetcode 807. Max Increase to Keep City Skyline https://leetcode.com/problems/max-increase-to-keep-city-skyline/ Max Increase to Keep City Skyline - 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 각 행과 열의 최댓값을 구하고 최대 increase할 수 있는 높이는 두 최댓값 중 작은 값이므로 두 값중 작은 값에서 기존 값을 더한 값들을 리턴한다. class Solution { public: int maxIncreaseKeeping.. 2020. 7. 12.
30★★] Leetcode 1010. Pairs of Songs With Total Durations Divisible by 60 Pairs of Songs With Total Durations Divisible by 60 - 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 #시간초과주의 for문 2번 돌리면 시간초과난다. 앞에 더해서 나머지가 0이 되는 숫자 갯수만큼 pair의 갯수가 늘어난다. class Solution { public: int numPairsDivisibleBy60(vector& time) { int vis[60] = {0}; int ans = 0; for(int i =.. 2020. 7. 10.