Python 썸네일형 리스트형 [리트코드(LeetCode)] 238. Product or Array Except Self - Python leetcode.com/problems/product-of-array-except-self/ Product of Array Except Self - 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 - 를 학습하면서 수록된 코드를 참고하였습니다. - 풀이 문제 제약 상 나눗셈을 사용할 수 없게되어 있었다. 현재 index의 왼쪽 원소들의 곱과 오른쪽 원소들의 곱을 구해 두 값을 곱하는 방법을 이용하였다. 먼저 nums[i]의 왼쪽에 있는 값들의 곱을 output[i.. [리트코드(LeetCode)] 15. 3Sum - Python leetcode.com/problems/3sum/ 3Sum - 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 - 를 학습하면서 수록된 코드를 참고하였습니다. - 풀이 1. 부르트 포스로 계산 -> 타임아웃 발생 for문을 3번 사용해서 풀이하는 단순한 방법으로 O(n^3)의 시간복잡도를 가지는 방법이다. for 문을 들어가서 해당 인덱스가 가리키는 리스트의 값이 바로 이전 원소 값과 동일하다면 continue 시켜줘서 중복을 제거한다. 리트코드에서 이 방법은 타.. [리트코드(LeetCode)] 42. Trapping Rain Water - Python leetcode.com/problems/trapping-rain-water/ Trapping Rain Water - 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 - 를 학습하면서 수록된 코드를 참고하였습니다. - 풀이 1. 투 포인터를 이용 두 개의 포인터가 각각 리스트의 좌, 우에서 시작한다. 현재 포인터가 가리키고 있는 인덱스를 left, right에 저장하고, 포인터가 지나왔던 자리 중 가장 높았던 값을 left_max, right_max에 저장한다. 두.. 이전 1 다음