K 'th Boom Number | C # program to find K 'th Boom number ; This function uses queue data structure to K 'th Boom number ; Create an empty queue of strings ; Enqueue an empty string ; counter for K 'th element ; This loop checks the value of count to become equal to K when value of count will be equals to k we will print the Boom number ; current Boom number ; Store current Boom number before changing it ; Append "2" to string s1 and enqueue it ; Check if count == k ; K 'th Boom number ; Append "3" to string s2 and enqueue it . Note that s2 contains the previous front ; Check if count == k ; K 'th Boom number ; Driver code
using System ; using System . Collections ; class GFG { static void boomNumber ( long k ) { Queue q = new Queue ( ) ; q . Enqueue ( " " ) ; long count = 0 ; while ( count <= k ) { string s1 = ( string ) q . Dequeue ( ) ; string s2 = s1 ; s1 += "2" ; q . Enqueue ( s1 ) ; count ++ ; if ( count == k ) { Console . Write ( s1 ) ; break ; } s2 += "3" ; q . Enqueue ( s2 ) ; count ++ ; if ( count == k ) { Console . Write ( s2 ) ; break ; } } return ; } public static void Main ( string [ ] arg ) { long k = 1000000 ; boomNumber ( k ) ; } }