-
-
2022-10-18
-
__
Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.
(i.e., `[0,1,2,4,5,6,7]` might become `[4,5,6,7,0,1,2]`).
Find the minimum element.
The array ma…
-
In a 2D grid of `0`s and `1`s, we change at most one `0` to a `1`.
After, what is the size of the largest island? (An island is a 4-directionally connected group of `1`s).
Example 1:
…
-
Equations are given in the format `A / B = k`, where `A` and `B` are variables represented as strings, and `k` is a real number (floating point number). Given some queries, return the answers. If t…
-
这一周学会了git和GitHub的使用,成功pr了代码,但在命名上有问题。
在刷lleetcode上面的题目时,方法有问题,不能完全把代码背下来,也没有刷够五遍,下周要安排更多的时间去学习。
//leetcode 105
class Solution {
// start from first preorder element
int pre_idx = 0;
int[] …
-
Given the `root` of a binary tree, each node in the tree has a distinct value.
After deleting all nodes with a value in `to_delete`, we are left with a forest (a disjoint union of trees).
Retur…
-
![image](https://user-images.githubusercontent.com/47746159/84684607-2e1ef980-af39-11ea-97c6-fc60ca0dfd20.png)
```
class Solution:
def buildTree(self, preorder: List[int], inorder: List[int]) -…
-
思路:先遍历字符串,用char型数组代替hash,找到不满足条件的字符。这些字符将长字符串切割为了一个个的子串。问题就变为了再对每个子串求同样的问题。
class Solution {
public:
int longestSubstring(string s, int k) {
if(s.size() < k) return 0;
int ans = 0;
…
-
给定一个包含 m x n 个元素的矩阵(m 行, n 列),请按照顺时针螺旋顺序,返回矩阵中的所有元素。
```
示例 1:
输入:
[
[ 1, 2, 3 ],
[ 4, 5, 6 ],
[ 7, 8, 9 ]
]
输出: [1,2,3,6,9,8,7,4,5]
示例 2:
输入:
[
[1, 2, 3, 4],
[5, 6, 7, 8]…