본문 바로가기

알고리즘 문제풀이/leetcode142

[leetcode 62]Unique Paths A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner of the grid (marked 'Finish' in the diagram below). How many possible unique paths are there? Example 1: Input: m = 3, n = 7 Output: 28 Example 2: Input: m = 3, n = 2 Output: 3 Expl.. 2020. 10. 27.
[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.