리트코드 5

[리트코드] 42. Trapping Rain Water <Java>

문제 https://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 풀이 내 풀이 : 왼쪽에서 부터 오른쪽으로 가장 최근에 높았던 높이에서 더 높은 높이를 만나면 그 사이의 값들의 높이차를 더해주었다. 위의 행동을 반대방향으로 한번 더 했다. 이 때, 주의할점은 같은 것을 두번 더하지 않기 위해 HashSet을 이용하여 문제를 풀었다. class S..

[리트코드] 238. Product of Array Except Self <Java>

문제 https://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 현재 인덱스의 수를 제외한 나머지 수들의 곱을 연산하는 문제( 단, 나눗셈 연산을 사용하지 않는다.) 풀이 문제의 조건이 없다면 모든 nums 배열의 수를 곱한 뒤 현재수를 나누기를 해주면 쉬운 문제지만, 나눗셈 연산을 하지않고 푸는 문제기 때문에 나..

[리트코드] Different Ways To Add Parentheses <Java>

문제 https://leetcode.com/problems/different-ways-to-add-parentheses/submissions/ Different Ways to Add Parentheses - 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 수식으로 만들어 낼 수 있는 결과 값의 리스트를 리턴하면 되는 문제 풀이 완전탐색을 이용하여 문제를 푼다. 알고리즘 순서 연산자를 만나면, 연산자 기준으로 왼쪽과 오른쪽을 나눠 재귀적으로 다시 함수에 넣어준다. ..

[리트코드] sliding-window-maximum (슬라이딩 윈도우) <Java>

https://leetcode.com/problems/sliding-window-maximum/ Sliding Window Maximum - 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 = [ 1, 2, 3, 4, 2,] k = 2 일 때, answer = [2, 3, 4, 4] 를 반환하면 된다. Sliding Window(슬라이딩 윈도우) 알고리즘을 활용하여 문제를 풀었다. 다른..