https://leetcode.com/problems/shortest-way-to-form-string/ (premium)
You are given two strings A and B (consisting of lowercase English alphabets). Your aim is form string A by concatenating multiple copies of string B. However, before concatenating a copy of string B, you can remove any number of characters from it. How many times of B shoulde be used at least to form A?
Example 1:
Input:
A = 'ZAZA'
B = 'BAZ'
Output:
3Explanation:
You can form string by concatenating three copies of string B as follows: ‘##Z’ + ‘#AZ’ + ‘#A#’.(# denotes the characters removed from string B).
Advanced:
Example 2:
Input:
A = 'ZAZAE'
B = 'BAZE'
Output:
4In this case, you can form string by concatenating three copies of string B as follows: ‘##Z#’ + ‘#AZ#’ + ‘#A#E’.(# denotes the characters removed from string B).
How many times of B shoulde be used at least to form A?