Geeksforgeeks

X

DAYS

:

HOUR

:

MINS

:

SEC

Error

Copied to Clipboard

Given string **s** that is appended with a number at last. The task is to check whether the length of string excluding that number is equal to that number.

**Example 1:**

**Input:** s = "geeks5"
**Output:** 1
**Explanation:** Length of **geeks** is 5
and the last number is also 5.

**Example 2:**

**Input:** s = "geek5"
**Output:** 0
**Explanation:** Length of **geek** is 4
and the last number is 5.

**User Task:**

Your task is to complete the function ** isSame() **which takes a single string as input and returns 1 in case the answer is true, otherwise 0. You do not need to take any input or print anything.

**Expected Time Complexity: **O(|s|)

**Expected Auxiliary Space: **O(1)

**Constraints:**

1 <= |s| <= 10^{5}

We are replacing the old Disqus forum with the new Discussions section given below.

Click here to view old Disqus comments.

Click here to view old Disqus comments.

Login to report an issue on this page.

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

YesLoading...

String with numbers at its end

...