The program must accept an integer N as the input. The task is to check whether the digits in the number are in increasing order from left to right. If they are, the program should print YES. Otherwise, it should print NO.
Boundary Condition(s):
1 <= N <= 10^8
Input Format:
The first line contains the number N.
Output Format:
The first line contains either YES or NO.
Example Input/Output 1:
Input:
12345
Output:
YES
Explanation:
The digits in the number 12345 are in increasing order from left to right.
Example Input/Output 2:
Input:
120345
Output:
NO
Explanation:
The digits in the number 120345 are not in increasing order since 2 is followed by 0.
n = input().strip()
if all(n[i] < n[i+1] for i in range(len(n)-1)):
print("YES")
else:
print("NO")
#include<stdio.h>
#include<stdbool.h>
bool isIncreasingOrder(char num[]) {
for(int i = 0; num[i+1] != ' '; i++) {
if(num[i] >= num[i+1]) return false;
}
return true;
}
int main() {
char num[10];
scanf("%s", num);
if(isIncreasingOrder(num)) {
printf("YES");
} else {
printf("NO");
}
return 0;
}
#include <iostream>
#include <string>
using namespace std;
bool isIncreasingOrder(string num) {
for(int i = 0; i < num.size()-1; i++) {
if(num[i] >= num[i+1]) return false;
}
return true;
}
int main() {
string num;
cin >> num;
if(isIncreasingOrder(num)) {
cout << "YES";
} else {
cout << "NO";
}
return 0;
}
import java.util.Scanner;
public class IncreasingOrderCheck {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String num = sc.next();
boolean isIncreasing = true;
for(int i = 0; i < num.length()-1; i++) {
if(num.charAt(i) >= num.charAt(i+1)) {
isIncreasing = false;
break;
}
}
System.out.println(isIncreasing ? "YES" : "NO");
}
}