logo CodeStepByStep logo

is_subsequence

Language/Type: PHP recursion string return

Write a recursive function named is_subsequence that accepts two string parameters, and returns if the second string is a subsequence of the first string. A string is a subsequence of another if it contains the same letters in the same order, but not necessary consecutively. You can assume both strings are already lowercased.

Constraints:

  • Do not declare any global variables or any auxiliary data structures.
  • Do not use any loops; you must use recursion.
Function: Write a PHP function as described, not a complete program.

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.