X

DAYS

:

HOUR

:

MINS

:

SEC

Loading...

Copied to Clipboard
Compare two Large Numbers
Basic Accuracy: 46.74% Submissions: 689 Points: 1

You will be given two numbers a and b. Your task is to print 1 if a < b, print 2 if a > b and print 3 if a = b.

Example 1:

Input:
a = 1234
b = 12345
Output: 1
Explanation: a < b so answer is 1.

Example 2:

Input:
a = 100
b = 1
Output: 2
Explanation: a > b, so answer is 2.

User Task:
Your task is to complete the function check() which takes 2 arguments(string a, string b) and returns the answer. You need not take input or print anything.

Expected Time Complexity: O(|a| + |b|).
Expected Auxiliary Space: O(|a| - |b|).

Constraints:
1 ≤ |a|, |b| ≤ 155

'0' ≤  ai,b ≤  '9'

We are replacing the old Disqus forum with the new Discussions section given below.
Click here to view old Disqus comments.

to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

My Submissions:

Login to access your submissions.

Compare two Large Numbers