FastPrepCheck a Cyclic Next-Character String

Check a Cyclic Next-Character String

ZipRecruiter logoZipRecruiter● EasyNEW GRADOA
Learn

Problem statement

You are given two equal-length lowercase strings, source and target.

Return true if every character in target is the next lowercase English letter after the character at the same position in source. The successor of z is a. Otherwise, return false.

Function

isNextCharacterString(source: String, target: String) → boolean

Examples

Example 1

source = "az"target = "ba"return = true

a advances to b, and z wraps to a.

Example 2

source = "abc"target = "abd"return = false

The first position fails because the successor of a is b, not a.

Constraints

  • 1 <= source.length == target.length <= 100000
  • Both strings contain only lowercase English letters.

More ZipRecruiter problems

See ZipRecruiter hiring insights
public boolean isNextCharacterString(String source, String target) {
    // Write your code here.
}
source"az"
target"ba"
expectedtrue
Checking account…