Implement the function max_non_overlapping_substrings which takes two strings, s and p, and returns a list of integers. The list indicates the maximum number of non-overlapping occurrences of the string p found in string s up to each position in s.
Functionality Requirements:
The function should calculate how many times p can occur non-overlapping in s from the start of s up to each character.
The function should construct a dynamic programming table to keep track of the maximum occurrences of p that can be found in s as we iterate through each character in s.
The final result should be a list where the index corresponds to the position in the string s, and the value at that index represents the maximum number of non-overlapping occurrences of p found up to that index.
Input/Output Requirements:
Input:
s (1 <= |s| <= 1000): a string in which to find non-overlapping occurrences of p.
p (1 <= |p| <= 1000): a string to search for within s.
Output:
The function should return a list of integers, with the length equal to len(s) + 1, where each integer represents the maximum number of non-overlapping occurrences of p found in s up to each index.
Example:
python
# Input
s = "abababab"
p = "ab"
# Output
[0, 1, 1, 2, 2, 3, 3, 4, 4]
File Requirement:
The solution must be written in a file called /app/solution.py.