Skip to content

Commit d88ca28

Browse files
committed
Create README - LeetHub
1 parent 89dd95e commit d88ca28

File tree

1 file changed

+52
-0
lines changed
  • 3097-shortest-subarray-with-or-at-least-k-ii

1 file changed

+52
-0
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<h2><a href="https://leetcode.com/problems/shortest-subarray-with-or-at-least-k-ii/">3097. Shortest Subarray With OR at Least K II</a></h2><h3>Medium</h3><hr><div><p>You are given an array <code>nums</code> of <strong>non-negative</strong> integers and an integer <code>k</code>.</p>
2+
3+
<p>An array is called <strong>special</strong> if the bitwise <code>OR</code> of all of its elements is <strong>at least</strong> <code>k</code>.</p>
4+
5+
<p>Return <em>the length of the <strong>shortest</strong> <strong>special</strong> <strong>non-empty</strong> <span data-keyword="subarray-nonempty">subarray</span> of</em> <code>nums</code>, <em>or return</em> <code>-1</code> <em>if no special subarray exists</em>.</p>
6+
7+
<p>&nbsp;</p>
8+
<p><strong class="example">Example 1:</strong></p>
9+
10+
<div class="example-block">
11+
<p><strong>Input:</strong> <span class="example-io">nums = [1,2,3], k = 2</span></p>
12+
13+
<p><strong>Output:</strong> <span class="example-io">1</span></p>
14+
15+
<p><strong>Explanation:</strong></p>
16+
17+
<p>The subarray <code>[3]</code> has <code>OR</code> value of <code>3</code>. Hence, we return <code>1</code>.</p>
18+
</div>
19+
20+
<p><strong class="example">Example 2:</strong></p>
21+
22+
<div class="example-block">
23+
<p><strong>Input:</strong> <span class="example-io">nums = [2,1,8], k = 10</span></p>
24+
25+
<p><strong>Output:</strong> <span class="example-io">3</span></p>
26+
27+
<p><strong>Explanation:</strong></p>
28+
29+
<p>The subarray <code>[2,1,8]</code> has <code>OR</code> value of <code>11</code>. Hence, we return <code>3</code>.</p>
30+
</div>
31+
32+
<p><strong class="example">Example 3:</strong></p>
33+
34+
<div class="example-block">
35+
<p><strong>Input:</strong> <span class="example-io">nums = [1,2], k = 0</span></p>
36+
37+
<p><strong>Output:</strong> <span class="example-io">1</span></p>
38+
39+
<p><strong>Explanation:</strong></p>
40+
41+
<p>The subarray <code>[1]</code> has <code>OR</code> value of <code>1</code>. Hence, we return <code>1</code>.</p>
42+
</div>
43+
44+
<p>&nbsp;</p>
45+
<p><strong>Constraints:</strong></p>
46+
47+
<ul>
48+
<li><code>1 &lt;= nums.length &lt;= 2 * 10<sup>5</sup></code></li>
49+
<li><code>0 &lt;= nums[i] &lt;= 10<sup>9</sup></code></li>
50+
<li><code>0 &lt;= k &lt;= 10<sup>9</sup></code></li>
51+
</ul>
52+
</div>

0 commit comments

Comments
 (0)