본문 바로가기
728x90

Algorithm75

[LeetCode] 73. Set Matrix Zeroes Given an m x n integer matrix matrix, if an element is 0, set its entire row and column to 0's. you must do it in place. Example 1: Input: matrix = [[1,1,1], [1,0,1], [1,1,1]] Output: [[1,0,1], [0,0,0], [1,0,1]] Example 2: Input: matrix = [[0,1,2,0], [3,4,5,2], [1,3,1,5]] Output: [[0,0,0,0], [0,4,5,0], [0,3,1,0]] Constraints: m == matrix.length n == matrix[0].length 1 2024. 3. 13.
[LeetCode] 72. Edit Distance Given two strings word1 and word2, return the minimum number of operations required to convert word1 to word2. You have the following three operations permitted on a word: Insert a character Delete a character Replace a character Example 1: Input: word1 = "horse", word2 = "ros" Output: 3 Explanation: horse -> rorse (replace 'h' with 'r') rorse -> rose (remove 'r') rose -> ros (remove 'e') Exampl.. 2024. 3. 1.
[LeetCode] 71. Simplify Path Given a string path, which is an absolute path (starting with a slash '/') to a file or directory in a Unix-style file system, convert it to the simplified canonical path. In a Unix-style file system, a period '.' refers to the current directory, a double period '..' refers to the directory up a level, and any multiple consecutive slashes (i.e. '//') are treated as a single slash '/'. For this p.. 2024. 2. 27.
[LeetCode] 70. 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 Output: 2 Explanation: There are two ways to climb to the top. 1. 1 step + 1 step 2. 2 steps Example 2: Input: n = 3 Output: 3 Explanation: There are three ways to climb to the top. 1. 1 step + 1 step + 1 step 2... 2024. 2. 23.
728x90