Live Batches
Masterclasses
Menu
Free Courses
Account
Login / Sign Up

Check Whether Digits Are Strictly Increasing

Basic Acceptance 96.12% Points 10.00

You are given a non-negative integer n. Your task is to determine whether its digits, read from left to right, are strictly increasing.

The digits must satisfy the condition that each digit is greater than the digit immediately before it. If any digit is equal to or smaller than the previous digit, return No. Otherwise, return Yes.

Examples
Example 1

Input: n = 1259
Output: Yes
Explanation: Each digit is greater than the digit before it: 1 < 2 < 5 < 9.

Example 2

Input: n = 1231
Output: No
Explanation: The final digit, 1, is smaller than the preceding digit, 3, so the digits are not strictly increasing.

Example 3

Input: n = 7
Output: Yes
Explanation: A single-digit number satisfies the condition because there are no adjacent digits to compare.

Constraints
  • 0 = n = 10¹8
Companies
Apple ServiceNow Yahoo Flipkart
Topics
Data Structures Basics Searching Algorithms
Solution.cs C#JavaPythonC++Javascript

Unlock the code editor

Sign in to write, run, and submit your solution against the full test suite.

  • Run code against sample & hidden test cases
  • Save submissions and track your streak
  • Compare with editorial & community solutions