개발일지

심화 과정 15 일차

오늘도개발 2024. 2. 27. 15:46

1. 자료구조 및 알고리즘 15일차 수강하기

 

 -  다이나믹 프로그래밍(DP)

 

2. 새롭게 알게된 지식

 

 - DP : 이전의 결과값이 다음 결정에 필요할 때, 이전의 결과값을 업데이트 하면서 프로그래밍 하는 알고리즘

 

과제 1 : 최대 서브 배열 : https://leetcode.com/problems/maximum-subarray/

 

Maximum Subarray - LeetCode

Can you solve this real interview question? Maximum Subarray - Given an integer array nums, find the subarray with the largest sum, and return its sum.   Example 1: Input: nums = [-2,1,-3,4,-1,2,1,-5,4] Output: 6 Explanation: The subarray [4,-1,2,1] has t

leetcode.com

 

 

 - 접근 : 

 

 1. 음수가 나오는 순간 결과값이 작아짐으로 음수를 기준으로 특징 분석

 2. 누적합을 들고 다니다가 누적합이 음수가 되는 순간 누적합 0으로 변경

 3. 매번 최댓값 갱신

 

 - 코드 구현 : 

 

 

 

 

과제 2 : 계단 오르기 : https://leetcode.com/problems/climbing-stairs/

 

Climbing Stairs - LeetCode

Can you solve this real interview question? Climbing Stairs - You are climbing a staircase. It takes n steps to reach the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?   Example 1: Input: n = 2 Outpu

leetcode.com

 

 

 - 접근 : 

 

 

 - 코드 구현 : 

 

 

 

 

과제 3 : 집 도둑 : https://leetcode.com/problems/house-robber/

 

House Robber - LeetCode

Can you solve this real interview question? House Robber - You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent ho

leetcode.com

 

 

 - 접근 : 

 

 

 

 - 코드 구현 : 

 

'개발일지' 카테고리의 다른 글

Spring 과제 Lv1  (0) 2024.03.05
5주차 WIL  (0) 2024.03.03
심화 과정 14 일차  (0) 2024.02.26
4주차 WIL  (0) 2024.02.25
심화 과정 13 일차  (1) 2024.02.24