Skip to content

Commit

Permalink
Create README - GfG to GitHub
Browse files Browse the repository at this point in the history
  • Loading branch information
RahulDadhich26 committed Mar 3, 2025
1 parent 04b3a0b commit cfc62b5
Showing 1 changed file with 5 additions and 0 deletions.
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:&nbsp;</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 &lt;= arr.size() &lt;= <span style="font-size: 18px;">10</span><sup>5<br></sup>1 &lt;= arr[i] &lt;=&nbsp;<span style="font-size: 18px;">10</span><sup>9<br></sup>0 &lt;= x&lt;=&nbsp;<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>&nbsp;<code>Heap</code>&nbsp;<code>sliding-window</code>&nbsp;<code>Arrays</code>&nbsp;<code>Queue</code>&nbsp;

0 comments on commit cfc62b5

Please sign in to comment.