본문 바로가기

분류 전체보기351

[leetcode 64] Minimum Path Sum Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path. Note: You can only move either down or right at any point in time. Example: Input: [ [1,3,1], [1,5,1], [4,2,1] ] Output: 7 Explanation: Because the path 1→3→1→1→1 minimizes the sum. 문제 풀이: - dp 사용 - 가장 왼쪽 col이나 가장 위쪽 row는 각각 위쪽, 왼쪽에 위치한 이전 배열 값을 현재.. 2020. 10. 27.
[leetcode 96] Unique Binary Search Trees Given n, how many structurally unique BST's (binary search trees) that store values 1 ... n? 1부터 n까지 사용하여 만들 수 있는 bst 경우의 수 Example: Input: 3 Output: 5 Explanation: Given n = 3, there are a total of 5 unique BST's: Constraints: 1 2020. 10. 26.
[leetcode 139] Word Break Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, determine if s can be segmented into a space-separated sequence of one or more dictionary words. wordDict에 있는 단어들로 주어진 s를 빠짐없이 분리할 수 있는가 Note: The same word in the dictionary may be reused multiple times in the segmentation. You may assume the dictionary does not contain duplicate words. Example 1: Input: .. 2020. 10. 26.
[leetcode 70] Climbing Stairs You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top? 계단을 1 혹은 2개씩 오를 수 있을 때 목표지점까지 도달할 수 있는 방법? Example 1: Input: 2 Output: 2 Explanation: There are two ways to climb to the top. 1. 1 step + 1 step 2. 2 steps Example 2: Input: 3 Output: 3 Explanation: There are three ways to climb to .. 2020. 10. 26.