text: Queries to check if count of increasing and decreasing subarrays is same in given range | C # program for the above approach ; Function to check if given range have equal number of increasing as well as decreasing subarrays ; Traverse each query ; For 0 - based indexing ; Condition for same count of increasing & decreasing subarray ; Driver Code
code: using System ; class GFG { static void checkCount ( int [ ] A , int [ , ] Q , int q ) { for ( int i = 0 ; i < q ; i ++ ) { int L = Q [ i , 0 ] ; int R = Q [ i , 1 ] ; L -- ; R -- ; if ( ( A [ L ] < A [ L + 1 ] ) != ( A [ R - 1 ] < A [ R ] ) ) { Console . WriteLine ( " Yes " ) ; } else { Console . WriteLine ( " No " ) ; } } } public static void Main ( ) { int [ ] arr = { 11 , 13 , 12 , 14 } ; int [ , ] Q = { { 1 , 4 } , { 2 , 4 } } ; int q = Q . GetLength ( 0 ) ; checkCount ( arr , Q , q ) ; } }