DSAMaster Logo
DSAMaster
BackmediumStrings

Maximum Non-overlapping Substring Matches

Problem Description

Given an array of strings and an array of target strings, find the maximum number of non-overlapping substrings in the target array that are present in the string array.

Example 1
Input
{"substrings": ['abc', 'xy', '123'], "targets": ['x', '123', 'zy', 'xyz', 'abc', 'abxyz', 'xyzxyz']}
Output
5

Explanation: We can find five non-overlapping substrings 'x', '123', 'xyz', 'abc' and 'xyz'.

Constraints

  • The input arrays will only contain strings.
  • The output will always be a non-negative integer.
  • The input arrays will only contain a finite number of strings.
00:00
Loading...

Sign in to Solve

Access the full code editor, ThinkBuddy AI hints, and track your progress.

Sign in Free
Test Cases & Output
Enter test input here...
Click "Run Code" to execute