← 返回 amazon 的题目列表Count Permutable Substrings Matching UserID Pattern
类型:online_judge
amazon
Programming Problem: User ID Matching
Given two user ID strings userid1 and userid2, and an integer p. From userid2, select substrings every p characters apart with a length equal to userid1. Calculate how many such substrings can be permuted to match userid1.
Input Description:
Two strings userid1 and userid2 consisting of lowercase letters, both lengths not exceeding $10^5$.
An integer p, such that $1 \leq p \le 100$.
Output Description:
An integer, representing the number of substrings that can be permuted to match userid1.
Example 1:
Input: userid1 = "abcd", userid2 = "abdccdccbdabda", p = 3
Output: 2
Example 2:
Input: userid1 = "xyz", userid2 = "zyxzyzx", p = 1
Output: 3
Note that the solution should aim for efficiency.
Example
Input
"abcd"
"abdccdccbdabda"
3