FastPrepFastPrep
Problem Brief

Find the Substring

INTERNOA

Given s and x, determine the zero-based index of the first occurrence of x in s.

  • String s consists of lowercase letters in the range ascii[a-z].
  • String x consists of lowercase letters and may also contain a single wildcard character, *, that represents any one character.
  • Function Description

    Complete the function firstOccurrence in the editor below. The function must return an integer denoting the zero-based index of the first occurrence of string x in s. If x is not in s, return -1 instead.

    firstOccurrence has the following parameter(s):

    • string s: a string of lowercase letters
    • string x: a string of lowercase letters which may contain 1 instance of the wildcard character *

    : 𓏲🐋 ๋࣭ Credit to Rachel ࣪ ˖✩࿐࿔ 🌊

    1Example 1

    Input
    s = "xabcdey", x = "ab*de"
    Output
    1
    Explanation
    Example 1 illustration

    Constraints

    Limits and guarantees your solution can rely on.

    🧡
    public int firstOccurrence(String s, String x) {
      // write your code here
    }
    
    Input

    s

    "xabcdey"

    x

    "ab*de"

    Output

    1

    Sign in to submit your solution.