Find longest common substring

Given two strings 's1' and 's2', find the length of the longest common substring.

Hint

The algorithm systematically explores all possible combinations of character subsequences within the two strings by recursively removing characters from either string. It keeps track of the longest common subsequence found in each recursive step and ultimately returns the maximum length.

# Python implementation
def count(s1, s2):
  if s2 == "":
    return 0

  if s2 in s1:
    return len(s2)
  else:
    return max(count(s1, s2[1:]), count(s1, s2[:-1]))

s1 = "QuestionOfTheDay"
s2 = "NewQuestion"

print(count(s1, s2))
// Javascript implementation
function count(s1, s2) {
  if (s2 === "") {
    return 0;
  }

  if (s1.indexOf(s2) >= 0) {
    return s2.length;
  } else {
    return Math.max(count(s1, s2.slice(1)), count(s1, s2.slice(0, -1)));
  }
}

const s1 = "QuestionOfTheDay";
const s2 = "NewQuestion";

console.log(count(s1, s2));