![]() |
VOOZH | about |
Given a string S that represents an integer, the task is to check if the given string S represents an unsigned integer or not by constructing the DFA. If the given string represents an unsigned integer, then print "Unsigned integer". Otherwise, print "Not an unsigned integer".
Examples:
Input: S = "+4554"
Output: Not an unsigned integerInput: S = "1729"
Output: unsigned integer
Approach: Below is the transition states of DFA for the given problem:
Follow the steps below to solve the problem:
Below is the implementation of the above approach:
Unsigned integer
Time Complexity: O(N)
Auxiliary Space: O(1), since no extra space has been taken.