Skip to content

Commit 724ebec

Browse files
authored
feat: add new lc problems (doocs#794)
1 parent 6da3ac7 commit 724ebec

File tree

10 files changed

+331
-29
lines changed

10 files changed

+331
-29
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# [2235. 两整数相加](https://leetcode-cn.com/problems/add-two-integers)
2+
3+
[English Version](/solution/2200-2299/2235.Add%20Two%20Integers/README_EN.md)
4+
5+
## 题目描述
6+
7+
<!-- 这里写题目描述 -->
8+
9+
给你两个整数&nbsp;<code>num1</code> 和 <code>num2</code>,返回这两个整数的和。
10+
<p>&nbsp;</p>
11+
12+
<p><strong>示例 1:</strong></p>
13+
14+
<pre>
15+
<strong>输入:</strong>num1 = 12, num2 = 5
16+
<strong>输出:</strong>17
17+
<strong>解释:</strong>num1 是 12,num2 是 5 ,它们的和是 12 + 5 = 17 ,因此返回 17 。
18+
</pre>
19+
20+
<p><strong>示例 2:</strong></p>
21+
22+
<pre>
23+
<strong>输入:</strong>num1 = -10, num2 = 4
24+
<strong>输出:</strong>-6
25+
<strong>解释:</strong>num1 + num2 = -6 ,因此返回 -6 。
26+
</pre>
27+
28+
<p>&nbsp;</p>
29+
30+
<p><strong>提示:</strong></p>
31+
32+
<ul>
33+
<li><code>-100 &lt;= num1, num2 &lt;= 100</code></li>
34+
</ul>
35+
36+
37+
## 解法
38+
39+
<!-- 这里可写通用的实现逻辑 -->
40+
41+
<!-- tabs:start -->
42+
43+
### **Python3**
44+
45+
<!-- 这里可写当前语言的特殊实现逻辑 -->
46+
47+
```python
48+
49+
```
50+
51+
### **Java**
52+
53+
<!-- 这里可写当前语言的特殊实现逻辑 -->
54+
55+
```java
56+
57+
```
58+
59+
### **TypeScript**
60+
61+
```ts
62+
63+
```
64+
65+
### **...**
66+
67+
```
68+
69+
```
70+
71+
<!-- tabs:end -->
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# [2235. Add Two Integers](https://leetcode.com/problems/add-two-integers)
2+
3+
[中文文档](/solution/2200-2299/2235.Add%20Two%20Integers/README.md)
4+
5+
## Description
6+
7+
Given two integers <code>num1</code> and <code>num2</code>, return <em>the <strong>sum</strong> of the two integers</em>.
8+
<p>&nbsp;</p>
9+
<p><strong>Example 1:</strong></p>
10+
11+
<pre>
12+
<strong>Input:</strong> num1 = 12, num2 = 5
13+
<strong>Output:</strong> 17
14+
<strong>Explanation:</strong> num1 is 12, num2 is 5, and their sum is 12 + 5 = 17, so 17 is returned.
15+
</pre>
16+
17+
<p><strong>Example 2:</strong></p>
18+
19+
<pre>
20+
<strong>Input:</strong> num1 = -10, num2 = 4
21+
<strong>Output:</strong> -6
22+
<strong>Explanation:</strong> num1 + num2 = -6, so -6 is returned.
23+
</pre>
24+
25+
<p>&nbsp;</p>
26+
<p><strong>Constraints:</strong></p>
27+
28+
<ul>
29+
<li><code>-100 &lt;= num1, num2 &lt;= 100</code></li>
30+
</ul>
31+
32+
33+
## Solutions
34+
35+
<!-- tabs:start -->
36+
37+
### **Python3**
38+
39+
```python
40+
41+
```
42+
43+
### **Java**
44+
45+
```java
46+
47+
```
48+
49+
### **TypeScript**
50+
51+
```ts
52+
53+
```
54+
55+
### **...**
56+
57+
```
58+
59+
```
60+
61+
<!-- tabs:end -->
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# [2236. 判断根结点是否等于子结点之和](https://leetcode-cn.com/problems/root-equals-sum-of-children)
2+
3+
[English Version](/solution/2200-2299/2236.Root%20Equals%20Sum%20of%20Children/README_EN.md)
4+
5+
## 题目描述
6+
7+
<!-- 这里写题目描述 -->
8+
9+
<p>给你一个 <strong>二叉树 </strong>的根结点&nbsp;<code>root</code>,该二叉树由恰好&nbsp;<code>3</code>&nbsp;个结点组成:根结点、左子结点和右子结点。</p>
10+
11+
<p>如果根结点值等于两个子结点值之和,返回&nbsp;<code>true</code>&nbsp;,否则返回<em>&nbsp;</em><code>false</code> 。</p>
12+
13+
<p>&nbsp;</p>
14+
15+
<p><strong>示例 1:</strong></p>
16+
<img alt="" src="https://cdn.jsdelivr.net/gh/doocs/leetcode@main/solution/2200-2299/2236.Root%20Equals%20Sum%20of%20Children/images/graph3drawio.png" style="width: 281px; height: 199px;" />
17+
<pre>
18+
<strong>输入:</strong>root = [10,4,6]
19+
<strong>输出:</strong>true
20+
<strong>解释:</strong>根结点、左子结点和右子结点的值分别是 10 、4 和 6 。
21+
由于 10 等于 4 + 6 ,因此返回 true 。
22+
</pre>
23+
24+
<p><strong>示例 2:</strong></p>
25+
<img alt="" src="https://cdn.jsdelivr.net/gh/doocs/leetcode@main/solution/2200-2299/2236.Root%20Equals%20Sum%20of%20Children/images/graph3drawio-1.png" style="width: 281px; height: 199px;" />
26+
<pre>
27+
<strong>输入:</strong>root = [5,3,1]
28+
<strong>输出:</strong>false
29+
<strong>解释:</strong>根结点、左子结点和右子结点的值分别是 5 、3 和 1 。
30+
由于 5 不等于 3 + 1 ,因此返回 false 。
31+
</pre>
32+
33+
<p>&nbsp;</p>
34+
35+
<p><strong>提示:</strong></p>
36+
37+
<ul>
38+
<li>树只包含根结点、左子结点和右子结点</li>
39+
<li><code>-100 &lt;= Node.val &lt;= 100</code></li>
40+
</ul>
41+
42+
43+
## 解法
44+
45+
<!-- 这里可写通用的实现逻辑 -->
46+
47+
<!-- tabs:start -->
48+
49+
### **Python3**
50+
51+
<!-- 这里可写当前语言的特殊实现逻辑 -->
52+
53+
```python
54+
55+
```
56+
57+
### **Java**
58+
59+
<!-- 这里可写当前语言的特殊实现逻辑 -->
60+
61+
```java
62+
63+
```
64+
65+
### **TypeScript**
66+
67+
```ts
68+
69+
```
70+
71+
### **...**
72+
73+
```
74+
75+
```
76+
77+
<!-- tabs:end -->
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# [2236. Root Equals Sum of Children](https://leetcode.com/problems/root-equals-sum-of-children)
2+
3+
[中文文档](/solution/2200-2299/2236.Root%20Equals%20Sum%20of%20Children/README.md)
4+
5+
## Description
6+
7+
<p>You are given the <code>root</code> of a <strong>binary tree</strong> that consists of exactly <code>3</code> nodes: the root, its left child, and its right child.</p>
8+
9+
<p>Return <code>true</code> <em>if the value of the root is equal to the <strong>sum</strong> of the values of its two children, or </em><code>false</code><em> otherwise</em>.</p>
10+
11+
<p>&nbsp;</p>
12+
<p><strong>Example 1:</strong></p>
13+
<img alt="" src="https://cdn.jsdelivr.net/gh/doocs/leetcode@main/solution/2200-2299/2236.Root%20Equals%20Sum%20of%20Children/images/graph3drawio.png" style="width: 281px; height: 199px;" />
14+
<pre>
15+
<strong>Input:</strong> root = [10,4,6]
16+
<strong>Output:</strong> true
17+
<strong>Explanation:</strong> The values of the root, its left child, and its right child are 10, 4, and 6, respectively.
18+
10 is equal to 4 + 6, so we return true.
19+
</pre>
20+
21+
<p><strong>Example 2:</strong></p>
22+
<img alt="" src="https://cdn.jsdelivr.net/gh/doocs/leetcode@main/solution/2200-2299/2236.Root%20Equals%20Sum%20of%20Children/images/graph3drawio-1.png" style="width: 281px; height: 199px;" />
23+
<pre>
24+
<strong>Input:</strong> root = [5,3,1]
25+
<strong>Output:</strong> false
26+
<strong>Explanation:</strong> The values of the root, its left child, and its right child are 5, 3, and 1, respectively.
27+
5 is not equal to 3 + 1, so we return false.
28+
</pre>
29+
30+
<p>&nbsp;</p>
31+
<p><strong>Constraints:</strong></p>
32+
33+
<ul>
34+
<li>The tree consists only of the root, its left child, and its right child.</li>
35+
<li><code>-100 &lt;= Node.val &lt;= 100</code></li>
36+
</ul>
37+
38+
39+
## Solutions
40+
41+
<!-- tabs:start -->
42+
43+
### **Python3**
44+
45+
```python
46+
47+
```
48+
49+
### **Java**
50+
51+
```java
52+
53+
```
54+
55+
### **TypeScript**
56+
57+
```ts
58+
59+
```
60+
61+
### **...**
62+
63+
```
64+
65+
```
66+
67+
<!-- tabs:end -->
9.12 KB
Loading
9.21 KB
Loading

0 commit comments

Comments
 (0)