Skip to content

Commit

Permalink
71.py
Browse files Browse the repository at this point in the history
  • Loading branch information
huisuu committed Aug 31, 2024
1 parent 714c761 commit 1922ae1
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions HSKIM/71to80/71.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
def solution(nums):
n = len(nums)
dp = [1] * n

# nums의 각 숫자와 그 앞의 숫자를 비교
for i in range(n):
for j in range(i):
# nums[i]와 nums[j]를 비교하여, nums[i]가 더 큰 경우에만 처리
if nums[i] > nums[j]:
# 만들 수 있는 수열 중 최댓값을 저장
dp[i] = max(dp[i], dp[j]+1)

return max(dp) # 최댓값 반환

print(solution([3, 2, 1]))

0 comments on commit 1922ae1

Please sign in to comment.