HackwithInfy 2022 Questions

Revision en7, by im_surajkumarmohanty, 2022-03-10 06:58:20

Question1

You are given an array A of size N. Find the count of Good Subarrays in A. Since the answer may be a large return it modulo 10^9+7. A Good Subarray is one in which:- - The difference between minimum and second minimum elements is not more than D. - It is guaranteed that the size of the Good Subarray array is at least 2.

Input Format

  • The first line contains an integer N, denoting the number of elements in A.
  • The second line contains D. The next i lines of N contains integer describing A[i]

    Examples

    Input 1

    2 1 2 3

    Output

    0

    Explanation

    No Good Subarrays

    Input 2

    3 3 7 4 1

    Output

    3

    Explanation

    [0,1] , [0,2] , [1,2]

    Input 3

    3 1 3 7 8

    Output

    1

    Explanation

    [1,2]

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en7 English im_surajkumarmohanty 2022-03-10 06:58:20 25 Tiny change: ' 10^9+7.\nA Good S' -> ' 10^9+7.\n----------------\nA Good S'
en6 English im_surajkumarmohanty 2022-03-10 06:22:30 17
en5 English im_surajkumarmohanty 2022-03-10 06:20:37 0 (published)
en4 English im_surajkumarmohanty 2022-03-10 06:20:23 26 (saved to drafts)
en3 English im_surajkumarmohanty 2022-03-10 06:19:40 20
en2 English im_surajkumarmohanty 2022-03-10 06:18:50 57
en1 English im_surajkumarmohanty 2022-03-10 06:17:04 863 Initial revision (published)