GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

Friday, 20 May 2022

[Solution] Subarrays with length CodeChef Solution | CodeChef Problem Solution 2022

You are given an array A of length N.

Determine the count of subarrays of A which contain their length as an element.

Formally, count the number of pairs (L,R) (1LRN) such that: (RL+1){AL,AL+1,,AR}.

Solution Click Below:-  CLICK HERE

Input Format

  • First line will contain T, number of test cases. Then the test cases follow.

  • First line of each test case contains an integer N denoting the length of the array A.
  • Second line of each test case contains N space-separated integers A1,A2,,AN - denoting the array A.

Output Format

For each test case, output the count of subarrays containing their lengths.

Constraints

  • 1T1000
  • 1N2105
  • 1AiN
  • Sum of N over all test cases does not exceed 5105.

No comments:

Post a Comment