Company: Netcore_26oct
Difficulty: medium
Distinct ways Problem Description You are given two strings S and R . For a query (X, Y) , consider the substring of S from position X to position Y (1-based, inclusive). Count the number of distinct ways to form R using only characters of that substring: choose a set of character positions inside the substring, rearrange the chosen characters in any order so that they spell R . Two ways are distinct if at least one chosen position differs. Since the count can be very large, report it modulo 998244353 . If R cannot be formed, the answer is 0 . Answer Q such queries for each test case. Function Description Complete the function solve : vector<int> solve(int N, int M, string S, string R, int Q, vector<int> X, vector<int> Y) N : the length of S . M : the length of R . S : the string S . R : the string R . Q : the number of queries. X : the starting positions of the Q substrings. Y : the ending positions of the Q substrings. Returns the Q answers, in order, each modulo 99