String Search

Medium
Problem Statement

Find all occurrences of a pattern string within a text string using naive string matching algorithm.

Constraints

  • Case sensitive matching
  • Time Complexity: O(N × M)
  • Space Complexity: O(1)
  • N = length of text, M = length of pattern
Solution