https://leetcode.com/problems/two-sum/description/ 문제설명정수로 구성된 리스트가 주어질 때, 두개의 숫자를 더해 target이 되는 인덱스를 반환 문제해결2중 for문class Solution: def twoSum(self, nums: List[int], target: int) -> List[int]: for i in range(len(nums)-1): for j in range(i+1, len(nums)): if nums[i]+nums[j] == target: return [i, j] 백트래킹class Solution: def twoSum(self, nu..
https://leetcode.com/problems/trapping-rain-water/description/ 1. 문제설명각 높이를 나타내는 지도가 주어졌을 때, 얼만큼 물이 담길 수 있는지 계산 2. 문제해결[stack 이용]class Solution: def trap(self, height: List[int]) -> int: stack = [] water = height.copy() for i, h in enumerate(height): if stack and stack[-1][1] 현재 높이랑 마지막에 저장된 높이랑 비교하는 과정이 필요하므로 stack 이용stack이 들어 있고 현재 높이가 stack의 맨 끝 높이보다 크거나 같으면..