Print all numbers in given range having digits in strictly increasing order | Java program for the above approach ; Function to print all numbers in the range [ L , R ] having digits in strictly increasing order ; Iterate over the range ; Iterate over the digits ; Check if the current digit is >= the previous digit ; If the digits are in ascending order ; Driver code ; Given range L and R ; Function call
import java . util . * ; class GFG { static void printNum ( int L , int R ) { for ( int i = L ; i <= R ; i ++ ) { int temp = i ; int c = 10 ; int flag = 0 ; while ( temp > 0 ) { if ( temp % 10 >= c ) { flag = 1 ; break ; } c = temp % 10 ; temp /= 10 ; } if ( flag == 0 ) System . out . print ( i + " ▁ " ) ; } } public static void main ( String [ ] args ) { int L = 10 , R = 15 ; printNum ( L , R ) ; } }