Connection Status:
Competition Arena > DecipherabilityEasy
SRM 649 · 2015-01-29 · by tozangezan · Brute Force, String Manipulation
Class Name: DecipherabilityEasy
Return Type: String
Method Name: check
Arg Types: (string, string)
Problem Statement

Problem Statement

You had a non-empty string s but you lost it. Cat Snuke found the string and removed one character from the string. Later, Snuke gave you the string t. Can this be the string created from your string s?

You are given the Strings s and t. Return "Possible" (quotes for clarity) if t can be obtained from s by erasing exactly one character. Otherwise, return "Impossible". Note that the return value is case-sensitive.

Constraints

  • The number of characters in s will be between 1 and 50, inclusive.
  • Every character in s will be a lowercase letter ('a'-'z').
  • The number of characters in t will be between 1 and 50, inclusive.
  • Every character in t will be a lowercase letter ('a'-'z').
Examples
0)
"sunuke"
"snuke"
Returns: "Possible"

If Cat Snuke erase the first 'u' from s, it will equal to t.

1)
"snuke"
"skue"
Returns: "Impossible"

Swapping characters is not allowed.

2)
"snuke"
"snuke"
Returns: "Impossible"

Erasing nothing is not allowed.

3)
"snukent"
"snuke"
Returns: "Impossible"

Cat Snuke can erase exactly one character.

4)
"aaaaa"
"aaaa"
Returns: "Possible"

Submissions are judged against all 153 archived test cases, of which 5 are shown here. Case numbers match the judge’s.

Coding Area

Language: C++17 · define a public class DecipherabilityEasy with a public method string check(string s, string t) · 153 test cases · 2 s / 256 MB per case

Submitting as anonymous