text: Print Nth Stepping or Autobiographical number | C # implementation to find N 'th stepping natural Number ; Function to find the Nth stepping natural number ; Declare the queue ; Enqueue 1 , 2 , ... , 9 in this order ; Perform K operation on queue ; Get the ith Stepping number ; Perform Dequeue from the Queue ; If x mod 10 is not equal to 0 ; then Enqueue 10 x + ( x mod 10 ) - 1 ; Enqueue 10 x + ( x mod 10 ) ; If x mod 10 is not equal to 9 ; then Enqueue 10 x + ( x mod 10 ) + 1 ; Return the dequeued number of the K - th operation as the Nth stepping number ; Driver Code ; initialise K
code: using System ; using System . Collections . Generic ; class GFG { static int NthSmallest ( int K ) { List < int > Q = new List < int > ( ) ; int x = 0 ; for ( int i = 1 ; i < 10 ; i ++ ) Q . Add ( i ) ; for ( int i = 1 ; i <= K ; i ++ ) { x = Q [ 0 ] ; Q . RemoveAt ( 0 ) ; if ( x % 10 != 0 ) { Q . Add ( x * 10 + x % 10 - 1 ) ; } Q . Add ( x * 10 + x % 10 ) ; if ( x % 10 != 9 ) { Q . Add ( x * 10 + x % 10 + 1 ) ; } } return x ; } public static void Main ( String [ ] args ) { int N = 16 ; Console . Write ( NthSmallest ( N ) ) ; } }