Skip to content

Commit 5fc6792

Browse files
committed
feat: add new lc problems
1 parent f9f70e5 commit 5fc6792

File tree

9 files changed

+393
-21
lines changed

9 files changed

+393
-21
lines changed

README_EN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
## Introduction
1616

17-
Complete solutions to [LeetCode](https://leetcode.com/problemset/all/), [LCOF](https://leetcode.cn/problemset/lcof/) and [LCCI](https://leetcode.cn/problemset/lcci/) problems, updated daily. Please give me a [star](https://github.com/doocs/leetcode) 🌟 if you like it.
17+
Complete solutions to LeetCode, LCOF and LCCI problems, updated daily. Please give me a [star](https://github.com/doocs/leetcode) 🌟 if you like it.
1818

1919
[中文文档](/README.md)
2020

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# [2387. Median of a Row Wise Sorted Matrix](https://leetcode.cn/problems/median-of-a-row-wise-sorted-matrix)
2+
3+
4+
[English Version](/solution/2300-2399/2387.Median%20of%20a%20Row%20Wise%20Sorted%20Matrix/README_EN.md)
5+
6+
7+
## 题目描述
8+
9+
10+
<!-- 这里写题目描述 -->
11+
12+
13+
<p>Given an <code>m x n</code> matrix <code>grid</code> containing an <strong>odd</strong> number of integers where each row is sorted in <strong>non-decreasing</strong> order, return <em>the <strong>median</strong> of the matrix</em>.</p>
14+
15+
<p>You must solve the problem in <code>O(m * log(n))</code> time complexity.</p>
16+
17+
<p>&nbsp;</p>
18+
<p><strong>Example 1:</strong></p>
19+
20+
<pre>
21+
<strong>Input:</strong> grid = [[1,1,2],[2,3,3],[1,3,4]]
22+
<strong>Output:</strong> 2
23+
<strong>Explanation:</strong> The elements of the matrix in sorted order are 1,1,1,2,<u>2</u>,3,3,3,4. The median is 2.
24+
</pre>
25+
26+
<p><strong>Example 2:</strong></p>
27+
28+
<pre>
29+
<strong>Input:</strong> grid = [[1,1,3,3,4]]
30+
<strong>Output:</strong> 3
31+
<strong>Explanation:</strong> The elements of the matrix in sorted order are 1,1,<u>3</u>,3,4. The median is 3.
32+
</pre>
33+
34+
<p>&nbsp;</p>
35+
<p><strong>Constraints:</strong></p>
36+
37+
<ul>
38+
<li><code>m == grid.length</code></li>
39+
<li><code>n == grid[i].length</code></li>
40+
<li><code>1 &lt;= m, n &lt;= 500</code></li>
41+
<li><code>m</code> and <code>n</code> are both odd.</li>
42+
<li><code>1 &lt;= grid[i][j] &lt;= 10<sup>6</sup></code></li>
43+
<li><code>grid[i]</code> is sorted in non-decreasing order.</li>
44+
</ul>
45+
46+
47+
48+
## 解法
49+
50+
51+
<!-- 这里可写通用的实现逻辑 -->
52+
53+
54+
<!-- tabs:start -->
55+
56+
57+
### **Python3**
58+
59+
60+
<!-- 这里可写当前语言的特殊实现逻辑 -->
61+
62+
63+
```python
64+
65+
```
66+
67+
68+
### **Java**
69+
70+
71+
<!-- 这里可写当前语言的特殊实现逻辑 -->
72+
73+
74+
```java
75+
76+
```
77+
78+
79+
### **TypeScript**
80+
81+
82+
```ts
83+
84+
```
85+
86+
87+
### **...**
88+
89+
90+
```
91+
92+
93+
```
94+
95+
96+
<!-- tabs:end -->
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# [2387. Median of a Row Wise Sorted Matrix](https://leetcode.com/problems/median-of-a-row-wise-sorted-matrix)
2+
3+
4+
[中文文档](/solution/2300-2399/2387.Median%20of%20a%20Row%20Wise%20Sorted%20Matrix/README.md)
5+
6+
7+
## Description
8+
9+
10+
<p>Given an <code>m x n</code> matrix <code>grid</code> containing an <strong>odd</strong> number of integers where each row is sorted in <strong>non-decreasing</strong> order, return <em>the <strong>median</strong> of the matrix</em>.</p>
11+
12+
<p>You must solve the problem in <code>O(m * log(n))</code> time complexity.</p>
13+
14+
<p>&nbsp;</p>
15+
<p><strong>Example 1:</strong></p>
16+
17+
<pre>
18+
<strong>Input:</strong> grid = [[1,1,2],[2,3,3],[1,3,4]]
19+
<strong>Output:</strong> 2
20+
<strong>Explanation:</strong> The elements of the matrix in sorted order are 1,1,1,2,<u>2</u>,3,3,3,4. The median is 2.
21+
</pre>
22+
23+
<p><strong>Example 2:</strong></p>
24+
25+
<pre>
26+
<strong>Input:</strong> grid = [[1,1,3,3,4]]
27+
<strong>Output:</strong> 3
28+
<strong>Explanation:</strong> The elements of the matrix in sorted order are 1,1,<u>3</u>,3,4. The median is 3.
29+
</pre>
30+
31+
<p>&nbsp;</p>
32+
<p><strong>Constraints:</strong></p>
33+
34+
<ul>
35+
<li><code>m == grid.length</code></li>
36+
<li><code>n == grid[i].length</code></li>
37+
<li><code>1 &lt;= m, n &lt;= 500</code></li>
38+
<li><code>m</code> and <code>n</code> are both odd.</li>
39+
<li><code>1 &lt;= grid[i][j] &lt;= 10<sup>6</sup></code></li>
40+
<li><code>grid[i]</code> is sorted in non-decreasing order.</li>
41+
</ul>
42+
43+
44+
45+
## Solutions
46+
47+
48+
<!-- tabs:start -->
49+
50+
51+
### **Python3**
52+
53+
54+
```python
55+
56+
```
57+
58+
59+
### **Java**
60+
61+
62+
```java
63+
64+
```
65+
66+
67+
### **TypeScript**
68+
69+
70+
```ts
71+
72+
```
73+
74+
75+
### **...**
76+
77+
78+
```
79+
80+
81+
```
82+
83+
84+
<!-- tabs:end -->
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# [2393. Count Strictly Increasing Subarrays](https://leetcode.cn/problems/count-strictly-increasing-subarrays)
2+
3+
4+
[English Version](/solution/2300-2399/2393.Count%20Strictly%20Increasing%20Subarrays/README_EN.md)
5+
6+
7+
## 题目描述
8+
9+
10+
<!-- 这里写题目描述 -->
11+
12+
13+
<p>You are given an array <code>nums</code> consisting of <strong>positive</strong> integers.</p>
14+
15+
<p>Return <em>the number of <strong>subarrays</strong> of </em><code>nums</code><em> that are in <strong>strictly increasing</strong> order.</em></p>
16+
17+
<p>A <strong>subarray</strong> is a <strong>contiguous</strong> part of an array.</p>
18+
19+
<p>&nbsp;</p>
20+
<p><strong class="example">Example 1:</strong></p>
21+
22+
<pre>
23+
<strong>Input:</strong> nums = [1,3,5,4,4,6]
24+
<strong>Output:</strong> 10
25+
<strong>Explanation:</strong> The strictly increasing subarrays are the following:
26+
- Subarrays of length 1: [1], [3], [5], [4], [4], [6].
27+
- Subarrays of length 2: [1,3], [3,5], [4,6].
28+
- Subarrays of length 3: [1,3,5].
29+
The total number of subarrays is 6 + 3 + 1 = 10.
30+
</pre>
31+
32+
<p><strong class="example">Example 2:</strong></p>
33+
34+
<pre>
35+
<strong>Input:</strong> nums = [1,2,3,4,5]
36+
<strong>Output:</strong> 15
37+
<strong>Explanation:</strong> Every subarray is strictly increasing. There are 15 possible subarrays that we can take.
38+
</pre>
39+
40+
<p>&nbsp;</p>
41+
<p><strong>Constraints:</strong></p>
42+
43+
<ul>
44+
<li><code>1 &lt;= nums.length &lt;= 10<sup>5</sup></code></li>
45+
<li><code>1 &lt;= nums[i] &lt;= 10<sup>6</sup></code></li>
46+
</ul>
47+
48+
49+
50+
## 解法
51+
52+
53+
<!-- 这里可写通用的实现逻辑 -->
54+
55+
56+
<!-- tabs:start -->
57+
58+
59+
### **Python3**
60+
61+
62+
<!-- 这里可写当前语言的特殊实现逻辑 -->
63+
64+
65+
```python
66+
67+
```
68+
69+
70+
### **Java**
71+
72+
73+
<!-- 这里可写当前语言的特殊实现逻辑 -->
74+
75+
76+
```java
77+
78+
```
79+
80+
81+
### **TypeScript**
82+
83+
84+
```ts
85+
86+
```
87+
88+
89+
### **...**
90+
91+
92+
```
93+
94+
95+
```
96+
97+
98+
<!-- tabs:end -->
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# [2393. Count Strictly Increasing Subarrays](https://leetcode.com/problems/count-strictly-increasing-subarrays)
2+
3+
4+
[中文文档](/solution/2300-2399/2393.Count%20Strictly%20Increasing%20Subarrays/README.md)
5+
6+
7+
## Description
8+
9+
10+
<p>You are given an array <code>nums</code> consisting of <strong>positive</strong> integers.</p>
11+
12+
<p>Return <em>the number of <strong>subarrays</strong> of </em><code>nums</code><em> that are in <strong>strictly increasing</strong> order.</em></p>
13+
14+
<p>A <strong>subarray</strong> is a <strong>contiguous</strong> part of an array.</p>
15+
16+
<p>&nbsp;</p>
17+
<p><strong class="example">Example 1:</strong></p>
18+
19+
<pre>
20+
<strong>Input:</strong> nums = [1,3,5,4,4,6]
21+
<strong>Output:</strong> 10
22+
<strong>Explanation:</strong> The strictly increasing subarrays are the following:
23+
- Subarrays of length 1: [1], [3], [5], [4], [4], [6].
24+
- Subarrays of length 2: [1,3], [3,5], [4,6].
25+
- Subarrays of length 3: [1,3,5].
26+
The total number of subarrays is 6 + 3 + 1 = 10.
27+
</pre>
28+
29+
<p><strong class="example">Example 2:</strong></p>
30+
31+
<pre>
32+
<strong>Input:</strong> nums = [1,2,3,4,5]
33+
<strong>Output:</strong> 15
34+
<strong>Explanation:</strong> Every subarray is strictly increasing. There are 15 possible subarrays that we can take.
35+
</pre>
36+
37+
<p>&nbsp;</p>
38+
<p><strong>Constraints:</strong></p>
39+
40+
<ul>
41+
<li><code>1 &lt;= nums.length &lt;= 10<sup>5</sup></code></li>
42+
<li><code>1 &lt;= nums[i] &lt;= 10<sup>6</sup></code></li>
43+
</ul>
44+
45+
46+
47+
## Solutions
48+
49+
50+
<!-- tabs:start -->
51+
52+
53+
### **Python3**
54+
55+
56+
```python
57+
58+
```
59+
60+
61+
### **Java**
62+
63+
64+
```java
65+
66+
```
67+
68+
69+
### **TypeScript**
70+
71+
72+
```ts
73+
74+
```
75+
76+
77+
### **...**
78+
79+
80+
```
81+
82+
83+
```
84+
85+
86+
<!-- tabs:end -->

0 commit comments

Comments
 (0)