|
| 1 | +--- |
| 2 | +comments: true |
| 3 | +difficulty: Easy |
| 4 | +edit_url: https://github.com/doocs/leetcode/edit/main/solution/3600-3699/3637.Trionic%20Array%20I/README_EN.md |
| 5 | +--- |
| 6 | + |
| 7 | +<!-- problem:start --> |
| 8 | + |
| 9 | +# [3637. Trionic Array I](https://leetcode.com/problems/trionic-array-i) |
| 10 | + |
| 11 | +[中文文档](/solution/3600-3699/3637.Trionic%20Array%20I/README.md) |
| 12 | + |
| 13 | +## Description |
| 14 | + |
| 15 | +<!-- description:start --> |
| 16 | + |
| 17 | +<p data-end="128" data-start="0">You are given an integer array <code data-end="37" data-start="31">nums</code> of length <code data-end="51" data-start="48">n</code>.</p> |
| 18 | + |
| 19 | +<p data-end="128" data-start="0">An array is <strong data-end="76" data-start="65">trionic</strong> if there exist indices <code data-end="117" data-start="100">0 < p < q < n − 1</code> such that:</p> |
| 20 | + |
| 21 | +<ul> |
| 22 | + <li data-end="170" data-start="132"><code data-end="144" data-start="132">nums[0...p]</code> is <strong>strictly</strong> increasing,</li> |
| 23 | + <li data-end="211" data-start="173"><code data-end="185" data-start="173">nums[p...q]</code> is <strong>strictly</strong> decreasing,</li> |
| 24 | + <li data-end="252" data-start="214"><code data-end="228" data-start="214">nums[q...n − 1]</code> is <strong>strictly</strong> increasing.</li> |
| 25 | +</ul> |
| 26 | + |
| 27 | +<p data-end="315" data-is-last-node="" data-is-only-node="" data-start="254">Return <code data-end="267" data-start="261">true</code> if <code data-end="277" data-start="271">nums</code> is trionic, otherwise return <code data-end="314" data-start="307">false</code>.</p> |
| 28 | + |
| 29 | +<p> </p> |
| 30 | +<p><strong class="example">Example 1:</strong></p> |
| 31 | + |
| 32 | +<div class="example-block"> |
| 33 | +<p><strong>Input:</strong> <span class="example-io">nums = [1,3,5,4,2,6]</span></p> |
| 34 | + |
| 35 | +<p><strong>Output:</strong> <span class="example-io">true</span></p> |
| 36 | + |
| 37 | +<p><strong>Explanation:</strong></p> |
| 38 | + |
| 39 | +<p>Pick <code data-end="91" data-start="84">p = 2</code>, <code data-end="100" data-start="93">q = 4</code>:</p> |
| 40 | + |
| 41 | +<ul> |
| 42 | + <li><code data-end="130" data-start="108">nums[0...2] = [1, 3, 5]</code> is strictly increasing (<code data-end="166" data-start="155">1 < 3 < 5</code>).</li> |
| 43 | + <li><code data-end="197" data-start="175">nums[2...4] = [5, 4, 2]</code> is strictly decreasing (<code data-end="233" data-start="222">5 > 4 > 2</code>).</li> |
| 44 | + <li><code data-end="262" data-start="242">nums[4...5] = [2, 6]</code> is strictly increasing (<code data-end="294" data-start="287">2 < 6</code>).</li> |
| 45 | +</ul> |
| 46 | +</div> |
| 47 | + |
| 48 | +<p><strong class="example">Example 2:</strong></p> |
| 49 | + |
| 50 | +<div class="example-block"> |
| 51 | +<p><strong>Input:</strong> <span class="example-io">nums = [2,1,3]</span></p> |
| 52 | + |
| 53 | +<p><strong>Output:</strong> <span class="example-io">false</span></p> |
| 54 | + |
| 55 | +<p><strong>Explanation:</strong></p> |
| 56 | + |
| 57 | +<p>There is no way to pick <code>p</code> and <code>q</code> to form the required three segments.</p> |
| 58 | +</div> |
| 59 | + |
| 60 | +<p> </p> |
| 61 | +<p><strong>Constraints:</strong></p> |
| 62 | + |
| 63 | +<ul> |
| 64 | + <li data-end="41" data-start="26"><code data-end="39" data-start="26">3 <= n <= 100</code></li> |
| 65 | + <li data-end="70" data-start="44"><code data-end="70" data-start="44">-1000 <= nums[i] <= 1000</code></li> |
| 66 | +</ul> |
| 67 | + |
| 68 | +<!-- description:end --> |
| 69 | + |
| 70 | +## Solutions |
| 71 | + |
| 72 | +<!-- solution:start --> |
| 73 | + |
| 74 | +### Solution 1 |
| 75 | + |
| 76 | +<!-- tabs:start --> |
| 77 | + |
| 78 | +#### Python3 |
| 79 | + |
| 80 | +```python |
| 81 | + |
| 82 | +``` |
| 83 | + |
| 84 | +#### Java |
| 85 | + |
| 86 | +```java |
| 87 | + |
| 88 | +``` |
| 89 | + |
| 90 | +#### C++ |
| 91 | + |
| 92 | +```cpp |
| 93 | + |
| 94 | +``` |
| 95 | + |
| 96 | +#### Go |
| 97 | + |
| 98 | +```go |
| 99 | + |
| 100 | +``` |
| 101 | + |
| 102 | +<!-- tabs:end --> |
| 103 | + |
| 104 | +<!-- solution:end --> |
| 105 | + |
| 106 | +<!-- problem:end --> |
0 commit comments