Skip to content

Commit

Permalink
feat: add new lc problem (doocs#2416)
Browse files Browse the repository at this point in the history
  • Loading branch information
yanglbme authored Mar 8, 2024
1 parent 230050e commit b303125
Show file tree
Hide file tree
Showing 4 changed files with 201 additions and 48 deletions.
74 changes: 74 additions & 0 deletions solution/3000-3099/3073.Maximum Increasing Triplet Value/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# [3073. 最大递增三元组](https://leetcode.cn/problems/maximum-increasing-triplet-value)

[English Version](/solution/3000-3099/3073.Maximum%20Increasing%20Triplet%20Value/README_EN.md)

<!-- tags: -->

## 题目描述

<!-- 这里写题目描述 -->

<p>给定一个数组&nbsp;<code>nums</code>,返回满足 <code>i &lt; j &lt; k</code> 且 <code>nums[i] &lt; nums[j] &lt; nums[k]</code>&nbsp;的三元组 <code>(i, j, k)</code> <em>&nbsp;</em>的 <strong>最大值</strong><i>。</i></p>

<p>三元组&nbsp;<code>(i, j, k)</code> &nbsp;&nbsp;<strong>值&nbsp;</strong>为&nbsp;<code>nums[i] - nums[j] + nums[k]</code>。</p>

<div id="gtx-trans" style="position: absolute; left: 274px; top: 102px;">
<div class="gtx-trans-icon">&nbsp;</div>
</div>

<p>&nbsp;</p>

<p><strong class="example">示例 1: </strong></p>

<pre>
输入:nums = [5,6,9]
输出:8
解释:对于一个递增的三元组,我们只有一个选择,那就是选择所有三个元素。三元组的值为 5 - 6 + 9 = 8。
</pre>

<p><strong class="example">示例 2: </strong></p>

<pre>
输入:nums = [1,5,3,6]
输出:4
解释:只有两个递增三元组:
(0, 1, 3):这个三元组的值为 nums[0] - nums[1] + nums[3] = 1 - 5 + 6 = 2。
(0, 2, 3):这个三元组的值为 nums[0] - nums[2] + nums[3] = 1 - 3 + 6 = 4。
因此答案是 4。
</pre>

<p>&nbsp;</p>

<p><strong>提示:</strong></p>

<ul>
<li><code>3 &lt;= nums.length &lt;= 10<sup>5</sup></code></li>
<li><code>1 &lt;= nums[i] &lt;= 10<sup>9</sup></code></li>
<li>输入数据保证至少一个三元组满足给定条件。</li>
</ul>

## 解法

### 方法一

<!-- tabs:start -->

```python

```

```java

```

```cpp

```

```go

```

<!-- tabs:end -->

<!-- end -->
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# [3073. Maximum Increasing Triplet Value](https://leetcode.com/problems/maximum-increasing-triplet-value)

[中文文档](/solution/3000-3099/3073.Maximum%20Increasing%20Triplet%20Value/README.md)

<!-- tags: -->

## Description

<p>Given an array <code>nums</code>, return <em>the <strong>maximum value</strong> of a triplet</em> <code>(i, j, k)</code> <em>such that</em> <code>i &lt; j &lt; k</code> <em>and</em> <code>nums[i] &lt; nums[j] &lt; nums[k]</code>.</p>

<p>The <strong>value</strong> of a triplet <code>(i, j, k)</code> is <code>nums[i] - nums[j] + nums[k]</code>.</p>

<div id="gtx-trans" style="position: absolute; left: 274px; top: 102px;">
<div class="gtx-trans-icon"> </div>
</div>

<p>&nbsp;</p>
<p><strong class="example">Example 1: </strong></p>

<div class="example-block" style="border-color: var(--border-tertiary); border-left-width: 2px; color: var(--text-secondary); font-size: .875rem; margin-bottom: 1rem; margin-top: 1rem; overflow: visible; padding-left: 1rem;">
<p><strong>Input: </strong> <span class="example-io" style="font-family: Menlo,sans-serif; font-size: 0.85rem;">nums = [5,6,9] </span></p>

<p><strong>Output: </strong> <span class="example-io" style="font-family: Menlo,sans-serif; font-size: 0.85rem;">8 </span></p>

<p><strong>Explanation: </strong> We only have one choice for an increasing triplet and that is choosing all three elements. The value of this triplet would be <code>5 - 6 + 9 = 8</code>.</p>
</div>

<p><strong class="example">Example 2: </strong></p>

<div class="example-block" style="border-color: var(--border-tertiary); border-left-width: 2px; color: var(--text-secondary); font-size: .875rem; margin-bottom: 1rem; margin-top: 1rem; overflow: visible; padding-left: 1rem;">
<p><strong>Input:</strong> <span class="example-io" style="font-family: Menlo,sans-serif; font-size: 0.85rem;"> nums = [1,5,3,6] </span></p>

<p><strong>Output:</strong> <span class="example-io" style="font-family: Menlo,sans-serif; font-size: 0.85rem;"> 4 </span></p>

<p><strong>Explanation: </strong> There are only two increasing triplets:</p>

<p><code>(0, 1, 3)</code>: The value of this triplet is <code>nums[0] - nums[1] + nums[3] = 1 - 5 + 6 = 2</code>.</p>

<p><code>(0, 2, 3)</code>: The value of this triplet is <code>nums[0] - nums[2] + nums[3] = 1 - 3 + 6 = 4</code>.</p>

<p>Thus the answer would be <code>4</code>.</p>
</div>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
<li><code>3 &lt;= nums.length &lt;= 10<sup>5</sup></code></li>
<li><code>1 &lt;= nums[i] &lt;= 10<sup>9</sup></code></li>
<li>The input is generated such that at least one triplet meets the given condition.</li>
</ul>

## Solutions

### Solution 1

<!-- tabs:start -->

```python

```

```java

```

```cpp

```

```go

```

<!-- tabs:end -->

<!-- end -->
49 changes: 25 additions & 24 deletions solution/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3059,30 +3059,31 @@
| 3046 | [分割数组](/solution/3000-3099/3046.Split%20the%20Array/README.md) | `数组`,`哈希表`,`计数` | 简单 | 第 386 场周赛 |
| 3047 | [求交集区域内的最大正方形面积](/solution/3000-3099/3047.Find%20the%20Largest%20Area%20of%20Square%20Inside%20Two%20Rectangles/README.md) | `几何`,`数组`,`数学` | 中等 | 第 386 场周赛 |
| 3048 | [标记所有下标的最早秒数 I](/solution/3000-3099/3048.Earliest%20Second%20to%20Mark%20Indices%20I/README.md) | `数组`,`二分查找` | 中等 | 第 386 场周赛 |
| 3049 | [标记所有下标的最早秒数 II](/solution/3000-3099/3049.Earliest%20Second%20to%20Mark%20Indices%20II/README.md) | `贪心`,`数组`,`二分查找` | 困难 | 第 386 场周赛 |
| 3050 | [Pizza Toppings Cost Analysis](/solution/3000-3099/3050.Pizza%20Toppings%20Cost%20Analysis/README.md) | | 中等 | 🔒 |
| 3051 | [Find Candidates for Data Scientist Position](/solution/3000-3099/3051.Find%20Candidates%20for%20Data%20Scientist%20Position/README.md) | | 简单 | 🔒 |
| 3052 | [Maximize Items](/solution/3000-3099/3052.Maximize%20Items/README.md) | | 困难 | 🔒 |
| 3053 | [Classifying Triangles by Lengths](/solution/3000-3099/3053.Classifying%20Triangles%20by%20Lengths/README.md) | | 简单 | 🔒 |
| 3054 | [Binary Tree Nodes](/solution/3000-3099/3054.Binary%20Tree%20Nodes/README.md) | | 中等 | 🔒 |
| 3055 | [Top Percentile Fraud](/solution/3000-3099/3055.Top%20Percentile%20Fraud/README.md) | | 中等 | 🔒 |
| 3056 | [Snaps Analysis](/solution/3000-3099/3056.Snaps%20Analysis/README.md) | | 中等 | 🔒 |
| 3057 | [Employees Project Allocation](/solution/3000-3099/3057.Employees%20Project%20Allocation/README.md) | | 困难 | 🔒 |
| 3058 | [Friends With No Mutual Friends](/solution/3000-3099/3058.Friends%20With%20No%20Mutual%20Friends/README.md) | | 中等 | 🔒 |
| 3059 | [Find All Unique Email Domains](/solution/3000-3099/3059.Find%20All%20Unique%20Email%20Domains/README.md) | | 简单 | 🔒 |
| 3060 | [User Activities within Time Bounds](/solution/3000-3099/3060.User%20Activities%20within%20Time%20Bounds/README.md) | | 困难 | 🔒 |
| 3061 | [Calculate Trapping Rain Water](/solution/3000-3099/3061.Calculate%20Trapping%20Rain%20Water/README.md) | | 困难 | 🔒 |
| 3062 | [Winner of the Linked List Game](/solution/3000-3099/3062.Winner%20of%20the%20Linked%20List%20Game/README.md) | | 简单 | 🔒 |
| 3063 | [Linked List Frequency](/solution/3000-3099/3063.Linked%20List%20Frequency/README.md) | | 中等 | 🔒 |
| 3064 | [Guess the Number Using Bitwise Questions I](/solution/3000-3099/3064.Guess%20the%20Number%20Using%20Bitwise%20Questions%20I/README.md) | | 中等 | 🔒 |
| 3065 | [超过阈值的最少操作数 I](/solution/3000-3099/3065.Minimum%20Operations%20to%20Exceed%20Threshold%20Value%20I/README.md) | | 简单 | 第 125 场双周赛 |
| 3066 | [超过阈值的最少操作数 II](/solution/3000-3099/3066.Minimum%20Operations%20to%20Exceed%20Threshold%20Value%20II/README.md) | | 中等 | 第 125 场双周赛 |
| 3067 | [在带权树网络中统计可连接服务器对数目](/solution/3000-3099/3067.Count%20Pairs%20of%20Connectable%20Servers%20in%20a%20Weighted%20Tree%20Network/README.md) | | 中等 | 第 125 场双周赛 |
| 3068 | [最大节点价值之和](/solution/3000-3099/3068.Find%20the%20Maximum%20Sum%20of%20Node%20Values/README.md) | | 困难 | 第 125 场双周赛 |
| 3069 | [将元素分配到两个数组中 I](/solution/3000-3099/3069.Distribute%20Elements%20Into%20Two%20Arrays%20I/README.md) | | 简单 | 第 387 场周赛 |
| 3070 | [元素和小于等于 k 的子矩阵的数目](/solution/3000-3099/3070.Count%20Submatrices%20with%20Top-Left%20Element%20and%20Sum%20Less%20Than%20k/README.md) | | 中等 | 第 387 场周赛 |
| 3071 | [在矩阵上写出字母 Y 所需的最少操作次数](/solution/3000-3099/3071.Minimum%20Operations%20to%20Write%20the%20Letter%20Y%20on%20a%20Grid/README.md) | | 中等 | 第 387 场周赛 |
| 3072 | [将元素分配到两个数组中 II](/solution/3000-3099/3072.Distribute%20Elements%20Into%20Two%20Arrays%20II/README.md) | | 困难 | 第 387 场周赛 |
| 3049 | [标记所有下标的最早秒数 II](/solution/3000-3099/3049.Earliest%20Second%20to%20Mark%20Indices%20II/README.md) | `贪心`,`数组`,`二分查找`,`堆(优先队列)` | 困难 | 第 386 场周赛 |
| 3050 | [Pizza Toppings Cost Analysis](/solution/3000-3099/3050.Pizza%20Toppings%20Cost%20Analysis/README.md) | `数据库` | 中等 | 🔒 |
| 3051 | [Find Candidates for Data Scientist Position](/solution/3000-3099/3051.Find%20Candidates%20for%20Data%20Scientist%20Position/README.md) | `数据库` | 简单 | 🔒 |
| 3052 | [Maximize Items](/solution/3000-3099/3052.Maximize%20Items/README.md) | `数据库` | 困难 | 🔒 |
| 3053 | [Classifying Triangles by Lengths](/solution/3000-3099/3053.Classifying%20Triangles%20by%20Lengths/README.md) | `数据库` | 简单 | 🔒 |
| 3054 | [Binary Tree Nodes](/solution/3000-3099/3054.Binary%20Tree%20Nodes/README.md) | `数据库` | 中等 | 🔒 |
| 3055 | [Top Percentile Fraud](/solution/3000-3099/3055.Top%20Percentile%20Fraud/README.md) | `数据库` | 中等 | 🔒 |
| 3056 | [Snaps Analysis](/solution/3000-3099/3056.Snaps%20Analysis/README.md) | `数据库` | 中等 | 🔒 |
| 3057 | [Employees Project Allocation](/solution/3000-3099/3057.Employees%20Project%20Allocation/README.md) | `数据库` | 困难 | 🔒 |
| 3058 | [Friends With No Mutual Friends](/solution/3000-3099/3058.Friends%20With%20No%20Mutual%20Friends/README.md) | `数据库` | 中等 | 🔒 |
| 3059 | [Find All Unique Email Domains](/solution/3000-3099/3059.Find%20All%20Unique%20Email%20Domains/README.md) | `数据库` | 简单 | 🔒 |
| 3060 | [User Activities within Time Bounds](/solution/3000-3099/3060.User%20Activities%20within%20Time%20Bounds/README.md) | `数据库` | 困难 | 🔒 |
| 3061 | [计算滞留雨水](/solution/3000-3099/3061.Calculate%20Trapping%20Rain%20Water/README.md) | `数据库` | 困难 | 🔒 |
| 3062 | [链表游戏的获胜者](/solution/3000-3099/3062.Winner%20of%20the%20Linked%20List%20Game/README.md) | `链表` | 简单 | 🔒 |
| 3063 | [链表频率](/solution/3000-3099/3063.Linked%20List%20Frequency/README.md) | `哈希表`,`链表`,`计数` | 中等 | 🔒 |
| 3064 | [使用按位查询猜测数字 I](/solution/3000-3099/3064.Guess%20the%20Number%20Using%20Bitwise%20Questions%20I/README.md) | `位运算`,`交互` | 中等 | 🔒 |
| 3065 | [超过阈值的最少操作数 I](/solution/3000-3099/3065.Minimum%20Operations%20to%20Exceed%20Threshold%20Value%20I/README.md) | `数组` | 简单 | 第 125 场双周赛 |
| 3066 | [超过阈值的最少操作数 II](/solution/3000-3099/3066.Minimum%20Operations%20to%20Exceed%20Threshold%20Value%20II/README.md) | `数组`,`模拟`,`堆(优先队列)` | 中等 | 第 125 场双周赛 |
| 3067 | [在带权树网络中统计可连接服务器对数目](/solution/3000-3099/3067.Count%20Pairs%20of%20Connectable%20Servers%20in%20a%20Weighted%20Tree%20Network/README.md) | `树`,`深度优先搜索`,`数组` | 中等 | 第 125 场双周赛 |
| 3068 | [最大节点价值之和](/solution/3000-3099/3068.Find%20the%20Maximum%20Sum%20of%20Node%20Values/README.md) | `贪心`,`位运算`,`树`,`数组`,`动态规划`,`排序` | 困难 | 第 125 场双周赛 |
| 3069 | [将元素分配到两个数组中 I](/solution/3000-3099/3069.Distribute%20Elements%20Into%20Two%20Arrays%20I/README.md) | `数组`,`模拟` | 简单 | 第 387 场周赛 |
| 3070 | [元素和小于等于 k 的子矩阵的数目](/solution/3000-3099/3070.Count%20Submatrices%20with%20Top-Left%20Element%20and%20Sum%20Less%20Than%20k/README.md) | `数组`,`矩阵`,`前缀和` | 中等 | 第 387 场周赛 |
| 3071 | [在矩阵上写出字母 Y 所需的最少操作次数](/solution/3000-3099/3071.Minimum%20Operations%20to%20Write%20the%20Letter%20Y%20on%20a%20Grid/README.md) | `数组`,`哈希表`,`计数`,`矩阵` | 中等 | 第 387 场周赛 |
| 3072 | [将元素分配到两个数组中 II](/solution/3000-3099/3072.Distribute%20Elements%20Into%20Two%20Arrays%20II/README.md) | `树状数组`,`线段树`,`数组`,`模拟` | 困难 | 第 387 场周赛 |
| 3073 | [最大递增三元组](/solution/3000-3099/3073.Maximum%20Increasing%20Triplet%20Value/README.md) | | 中等 | 🔒 |

## 版权

Expand Down
Loading

0 comments on commit b303125

Please sign in to comment.