Generate Bitonic Sequence of length N from integers in a given range | C # program for the above approach ; Function to construct bitonic sequence of length N from integers in the range [ L , R ] ; If sequence is not possible ; Store the resultant list ; If size of deque < n ; Add elements from start ; Print the stored in the list ; Driver Code ; Function Call
using System ; using System . Collections . Generic ; class GFG { public static void bitonicSequence ( int num , int lower , int upper ) { if ( num > ( upper - lower ) * 2 + 1 ) { Console . WriteLine ( - 1 ) ; return ; } List < int > ans = new List < int > ( ) ; for ( int i = 0 ; i < Math . Min ( upper - lower + 1 , num - 1 ) ; i ++ ) ans . Add ( upper - i ) ; for ( int i = 0 ; i < num - ans . Count ; i ++ ) ans . Insert ( 0 , upper - i - 1 ) ; Console . Write ( " [ " ) ; foreach ( int x in ans ) Console . Write ( x + " , ▁ " ) ; Console . Write ( " ] " ) ; } public static void Main ( String [ ] args ) { int N = 5 , L = 3 , R = 10 ; bitonicSequence ( N , L , R ) ; } }