Company: Netcore backend dev_2nov
Difficulty: medium
Distinct ways Problem Description You are given two strings, S and R. Determine, for a substring of S, in how many distinct ways the string R can be assembled using only characters drawn from that substring. Since the count can grow very large, print it modulo 998244353. Complete the function solve() provided in the editor. This function receives the following 7 parameters and returns the required answer. N the length of string S M the length of string R S the string S R the string R Q the number of queries X the starting position of the substring for each of the Q queries Y the ending position of the substring for each of the Q queries Notes A substring is a contiguous block of characters from a string. To assemble R from a substring of S: Choose any subset of character positions within that substring. Rearrange the chosen characters in whatever order forms R. Two ways count as distinct whenever they differ in at least one chosen position. Input Format for Custom Testing Note Use this