Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 6ded126

Browse filesBrowse files
committed
Added README.md file for Find the Power of K-Size Subarrays II
1 parent 317e45a commit 6ded126
Copy full SHA for 6ded126

File tree

Expand file treeCollapse file tree

1 file changed

+58
-0
lines changed
Filter options
  • 3523-find-the-power-of-k-size-subarrays-ii
Expand file treeCollapse file tree

1 file changed

+58
-0
lines changed
+58Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<h2><a href="https://leetcode.com/problems/find-the-power-of-k-size-subarrays-ii">Find the Power of K-Size Subarrays II</a></h2> <img src='https://img.shields.io/badge/Difficulty-Medium-orange' alt='Difficulty: Medium' /><hr><p>You are given an array of integers <code>nums</code> of length <code>n</code> and a <em>positive</em> integer <code>k</code>.</p>
2+
3+
<p>The <strong>power</strong> of an array is defined as:</p>
4+
5+
<ul>
6+
<li>Its <strong>maximum</strong> element if <em>all</em> of its elements are <strong>consecutive</strong> and <strong>sorted</strong> in <strong>ascending</strong> order.</li>
7+
<li>-1 otherwise.</li>
8+
</ul>
9+
10+
<p>You need to find the <strong>power</strong> of all <span data-keyword="subarray-nonempty">subarrays</span> of <code>nums</code> of size <code>k</code>.</p>
11+
12+
<p>Return an integer array <code>results</code> of size <code>n - k + 1</code>, where <code>results[i]</code> is the <em>power</em> of <code>nums[i..(i + k - 1)]</code>.</p>
13+
14+
<p>&nbsp;</p>
15+
<p><strong class="example">Example 1:</strong></p>
16+
17+
<div class="example-block">
18+
<p><strong>Input:</strong> <span class="example-io">nums = [1,2,3,4,3,2,5], k = 3</span></p>
19+
20+
<p><strong>Output:</strong> [3,4,-1,-1,-1]</p>
21+
22+
<p><strong>Explanation:</strong></p>
23+
24+
<p>There are 5 subarrays of <code>nums</code> of size 3:</p>
25+
26+
<ul>
27+
<li><code>[1, 2, 3]</code> with the maximum element 3.</li>
28+
<li><code>[2, 3, 4]</code> with the maximum element 4.</li>
29+
<li><code>[3, 4, 3]</code> whose elements are <strong>not</strong> consecutive.</li>
30+
<li><code>[4, 3, 2]</code> whose elements are <strong>not</strong> sorted.</li>
31+
<li><code>[3, 2, 5]</code> whose elements are <strong>not</strong> consecutive.</li>
32+
</ul>
33+
</div>
34+
35+
<p><strong class="example">Example 2:</strong></p>
36+
37+
<div class="example-block">
38+
<p><strong>Input:</strong> <span class="example-io">nums = [2,2,2,2,2], k = 4</span></p>
39+
40+
<p><strong>Output:</strong> <span class="example-io">[-1,-1]</span></p>
41+
</div>
42+
43+
<p><strong class="example">Example 3:</strong></p>
44+
45+
<div class="example-block">
46+
<p><strong>Input:</strong> <span class="example-io">nums = [3,2,3,2,3,2], k = 2</span></p>
47+
48+
<p><strong>Output:</strong> <span class="example-io">[-1,3,-1,3,-1]</span></p>
49+
</div>
50+
51+
<p>&nbsp;</p>
52+
<p><strong>Constraints:</strong></p>
53+
54+
<ul>
55+
<li><code>1 &lt;= n == nums.length &lt;= 10<sup>5</sup></code></li>
56+
<li><code>1 &lt;= nums[i] &lt;= 10<sup>6</sup></code></li>
57+
<li><code>1 &lt;= k &lt;= n</code></li>
58+
</ul>

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.