-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
04b3a0b
commit cfc62b5
Showing
1 changed file
with
5 additions
and
0 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
Difficulty: Medium/Longest Bounded-Difference Subarray/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<h2><a href="https://www.geeksforgeeks.org/problems/longest-bounded-difference-subarray/1">Longest Bounded-Difference Subarray</a></h2><h3>Difficulty Level : Difficulty: Medium</h3><hr><div class="problems_problem_content__Xm_eO"><p>Given an array of positive integers <strong>arr[] </strong>and a non-negative integer <strong>x</strong>, the task is to find the <strong>longest sub-array</strong> where the absolute difference between any two elements is not greater than <strong>x</strong>. <br>If multiple such subarrays exist, return the one that starts at the smallest index.</p> | ||
<p><strong>Examples: </strong></p> | ||
<pre><span style="font-size: 12pt;"><strong>Input: </strong>arr[] =<strong> </strong>[8, 4, 2, 6, 7], x = 4 </span><br><span style="font-size: 12pt;"><strong>Output: </strong>[4, 2, 6] </span><br><span style="font-size: 12pt;"><strong>Explanation: </strong>The sub-array described by index [1..3], i.e. [4, 2, 6] contains no such difference of two elements which is greater than 4.</span></pre> | ||
<pre><span style="font-size: 12pt;"><strong>Input:</strong> arr[] =<strong> </strong>[15, 10, 1, 2, 4, 7, 2], x = 5 </span><br><span style="font-size: 12pt;"><strong>Output: </strong>[2, 4, 7, 2] </span><br><span style="font-size: 12pt;"><strong>Explanation: </strong>The sub-array described by indexes [3..6], i.e. [2, 4, 7, 2] contains no such difference of two elements which is greater than 5. </span></pre> | ||
<p><strong>Constraints:<br></strong>1 <= arr.size() <= <span style="font-size: 18px;">10</span><sup>5<br></sup>1 <= arr[i] <= <span style="font-size: 18px;">10</span><sup>9<br></sup>0 <= x<= <span style="font-size: 18px;">10</span><sup>9</sup></p></div><br><p><span style=font-size:18px><strong>Topic Tags : </strong><br><code>Algorithms</code> <code>Heap</code> <code>sliding-window</code> <code>Arrays</code> <code>Queue</code> |