dfs 4

2024 10 30 1671. Minimum Number of Removals to Make Mountain Array

문제You may recall that an array arr is a mountain array if and only if:arr.length >= 3There exists some index i (0-indexed) with 0 arr[i + 1] > ... > arr[arr.length - 1]Given an integer array nums​​​, return the minimum number of elements to remove to make nums​​​ a mountain array.요약산 모양으로 왼쪽으로는 감소 오른쪽으로는 증가하는 최장 집합를 찾으면 된다.풀이dfs로 깊게 들어가면서 각 index (idx)에서 1. 이전 0~idx 까지 가장 긴 증가 부분집합의 길이2. 이후 idx..

알고리즘 2024.10.30

2024.10.22 2583. Kth Largest Sum in a Binary Tree (Java)

문제You are given the root of a binary tree and a positive integer k.The level sum in the tree is the sum of the values of the nodes that are on the same level.Return the kth largest level sum in the tree (not necessarily distinct). If there are fewer than k levels in the tree, return -1.Note that two nodes are on the same level if they have the same distance from the root.요약같은 depth에서 총 합의 크기가 k번..

알고리즘 2024.10.22

2024.10.22 LeetCode 1593. Split a String Into the Max Number of Unique Substrings

Given a string `s`, return _the maximum number of unique substrings that the given string can be split into_.You can split string `s` into any list of **non-empty substrings**, where the concatenation of the substrings forms the original string. However, you must split the substrings such that all of them are **unique**.A **substring** is a contiguous sequence of characters within a string.풀이 시간..

알고리즘 2024.10.22