Leetcode#221. Maximal Square
ProblemGiven an m x n binary matrix filled with 0‘s and 1‘s, find the largest square containing only 1‘s and return its area.
Example 1:
!https://assets.leetcode.com/uploads/2020/11/26/max1grid.jpg
123Input: matrix = [["1","0","1","0","0"],["1","0","1","1","1"],["1","1","1","1","1"],["1","0","0","1","0& ...
Leetcode#190. Reverse Bits
ProblemReverse bits of a given 32 bits unsigned integer.
Note:
Note that in some languages, such as Java, there is no unsigned integer type. In this case, both input and output will be given as a signed integer type. They should not affect your implementation, as the integer’s internal binary representation is the same, whether it is signed or unsigned.
In Java, the compiler represents the signed integers using 2’s complement notation. Therefore, in Example 2 above, the input represents the sig ...
Leetcode#67. Add Binary
ProblemGiven two binary strings a and b, return their sum as a binary string.
Example 1:
123Input: a = "11", b = "1"Output: "100"
Example 2:
123Input: a = "1010", b = "1011"Output: "10101"
Constraints:
1 <= a.length, b.length <= 10^4
a and b consist only of '0' or '1' characters.
Each string does not contain leading zeros except for the zero itself.
Solve123456789101112131415161718192021222324class Solution: ...
Leetcode#79. Word Search
進階leetcode212
ProblemGiven an m x n grid of characters board and a string word, return true if word exists in the grid.
The word can be constructed from letters of sequentially adjacent cells, where adjacent cells are horizontally or vertically neighboring. The same letter cell may not be used more than once.
Example 1:
!https://assets.leetcode.com/uploads/2020/11/04/word2.jpg
123Input: board = [["A","B","C","E"],["S","F","C" ...
Leetcode#212. Word Search II
簡易leetcode79
ProblemGiven an m x n board of characters and a list of strings words, return all words on the board.
Each word must be constructed from letters of sequentially adjacent cells, where adjacent cells are horizontally or vertically neighboring. The same letter cell may not be used more than once in a word.
Example 1:
!https://assets.leetcode.com/uploads/2020/11/07/search1.jpg
123Input: board = [["o","a","a","n"],["e","t",&quo ...
Leetcode#35. Search Insert Position
ProblemGiven a sorted array of distinct integers and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.
You must write an algorithm with O(log n) runtime complexity.
Example 1:
123Input: nums = [1,3,5,6], target = 5Output: 2
Example 2:
123Input: nums = [1,3,5,6], target = 2Output: 1
Example 3:
123Input: nums = [1,3,5,6], target = 7Output: 4
Constraints:
1 <= nums.length <= 10^4
10^4 <= nums[i] <= 10^4
...
Leetcode#100. Same Tree
ProblemGiven the roots of two binary trees p and q, write a function to check if they are the same or not.
Two binary trees are considered the same if they are structurally identical, and the nodes have the same value.
Example 1:
!https://assets.leetcode.com/uploads/2020/12/20/ex1.jpg
123Input: p = [1,2,3], q = [1,2,3]Output: true
Example 2:
!https://assets.leetcode.com/uploads/2020/12/20/ex2.jpg
123Input: p = [1,2], q = [1,null,2]Output: false
Example 3:
!https://assets.leetcode.com/upload ...
Leetcode#62. Unique Paths
123456789101112- [Leetcode]- [Python]- [medium]- [💡]- Math- Dynamic Programming- Combinatoricscover: /img/cover/leetcode.jpgcategories: Leetcode
ProblemThere is a robot on an m x n grid. The robot is initially located at the top-left corner (i.e., grid[0][0]). The robot tries to move to the bottom-right corner (i.e., grid[m - 1][n - 1]). The robot can only move either down or right at any point in time.
Given the two integers m and n, return the number of possible unique paths that the robot c ...
Leetcode#120. Triangle
leetcode62
ProblemGiven a triangle array, return the minimum path sum from top to bottom.
For each step, you may move to an adjacent number of the row below. More formally, if you are on index i on the current row, you may move to either index i or index i + 1 on the next row.
Example 1:
123456789Input: triangle = [[2],[3,4],[6,5,7],[4,1,8,3]]Output: 11Explanation: The triangle looks like: 2 3 4 6 5 74 1 8 3The minimum path sum from top to bottom is 2 + 3 + 5 + 1 = 11 (underlined above).
Exa ...
Leetcode#198. House Robber
可以先看看leetcode70
ProblemYou are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent houses have security systems connected and it will automatically contact the police if two adjacent houses were broken into on the same night.
Given an integer array nums representing the amount of money of each house, return the maximum amount of money you can rob tonight without ...