리트코드 사용법 3

[리트코드] 이진탐색 알고리즘: 33. Search in Rotated Sorted Array

https://leetcode.com/problems/search-in-rotated-sorted-array/ Search in Rotated Sorted 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가 k개만큼 로테이션된 상태로 주어진다. 이 문제의 핵심은 binary search 알고리즘을 사용하면서 구하는 mid가 로테이션된 부분인지 아닌지 판단하는 것이다. 오름차순 정렬된 배열에서..

알고리즘 2022.04.02

[리트코드] 정렬 관련 알고리즘 문제: 406. Queue Reconstruction by Height (JavaScript)

https://leetcode.com/problems/queue-reconstruction-by-height/ Queue Reconstruction by Height - 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 문제가 길어서 복잡해 보이지만 Example을 보면 쉽게 이해할 수 있다. 이중 배열 각 요소중 [0]은 키를, [1]은 내 앞에 선 사람 중 나와 키가 같거나 큰 사람 수를 나타낸다. 이에 맞게 배열을 재 정렬해서 반환하면 된다. 첫 번째로 일단 ..

알고리즘 2022.03.25

[리트코드] 삼각형 관련 알고리즘 2문제

[문제 1] https://leetcode.com/problems/largest-perimeter-triangle/ Largest Perimeter Triangle - 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로 가장 긴 삼각형을 만들 수 있는 조합을 찾아서 그 둘레를 반환하는 문제 삼각형은 가장 긴 변=a, 두 번째 긴 변=b, 제일 짧은 변=c 라고 했을 때 a int: sort = sorted(nums, reverse = True) fo..

알고리즘 2022.03.25