코딩테스트 준비 5

[Python] 리트코드 583. Delete Operation for Two Strings

https://leetcode.com/problems/delete-operation-for-two-strings/ Delete Operation for Two Strings - 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 먼저 word1이랑 word2에서 공통된 알파벳들을 알아낸다. 공통되지 않은 알파벳들은 조작되어야 하는 알파벳이므로 word1과 word2의 각 length를 비교해 그 차이만큼 답으로 리턴한다. 공통된 알파벳을 가려내는데 고려해야 하는 사항..

알고리즘 2021.12.02

[Python] 리트코드 309. Best Time to Buy and Sell Stock with Cooldown

https://leetcode.com/problems/best-time-to-buy-and-sell-stock-with-cooldown/ Best Time to Buy and Sell Stock with Cooldown - 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 이 문제는 [121. Best Time to Buy and Sell Stock] 이랑 [122. Best Time to Buy and Sell Stock II] 의 다음 단계라고 할 수 있다. 이..

알고리즘 2021.10.27

[Python] 리트코드 1014. Best Sightseeing Pair

https://leetcode.com/problems/best-sightseeing-pair/ Best Sightseeing Pair - 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 values[i] + values[j] + i - j 를 계산했을 때 최댓값을 구하는 문제이다. values[i] + values[j] + i - j 값이 최대가 되려면 values[i] + i는 최대가 되어야 하고 values[j] - j도 최대가 되어야 한다. values의 임..

알고리즘 2021.10.26

[Python] 리트코드 463. Island Perimeter

https://leetcode.com/problems/island-perimeter/ Island Perimeter - 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 grid = [[0,1,0,0], [1,1,1,0], [0,1,0,0], [1,1,0,0]] 그림처럼 1은 땅을 0은 물을 뜻한다. 이때 땅의 둘레를 구하는 문제 ==풀이== 1. 땅 두 칸이 붙어 있으면 겹치는 선이 한 개일 것이다. 2. 겹치는 것 생각하지 않고 각 네모의 둘레를 모두 구했을 때..

알고리즘 2021.10.19

[Python] 리트코드 1470 : Shuffle the Array (Array)

https://leetcode.com/problems/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 주어진 nums배열에서 0부터 n씩 건너뛰면서 숫자를 골라 새로운 배열을 만들어내면 된다. nums=[0,1,2,3,4,5], n=3이라면 nums[0]인 0이 새 배열의 첫 번째가 되고 3칸 뒤인 3이 두 번째가 된다. 3의 3칸 뒤는 배열을 한 바퀴 돌아서 0이 되야하는데 0은 이미 새 배열..

알고리즘 2021.06.08