Question: Netcore, Online Assessments conducted on 29th October, 2025 | Maximum remainder | Distinct ways
0
Entering edit mode

Question 1: Maximum remainder

You are given an array A containing N integers, where N is always even. In the array, exactly N/2 elements are even and N/2 elements are odd. You are also given an integer k. Choose one even element and one odd element from A. Let their sum be s. You need to compute the maximum possible value of the remainder (sum modulo k) over all such pairs.

Let's look at an example for better understanding:

Given

  • A = [1, 2, 3, 4]
  • k = 5

There are two evens (2, 4) and two odds (1, 3).

All pairs and remainders:

  • Pick 1 and 2  Sum = 3  3 % 5 = 3
  • Pick 1 and 4  Sum = 5  5 % 5 = 0
  • Pick 3 and 2  Sum = 5  5 % 5 = 0
  • Pick 3 and 4  Sum = 7  7 % 5 = 2

The maximum possible value of the remainder is 3. So the output is 3.


Question 2: Distinct ways

You are given two strings, S and R. Your task is to determine how many distinct ways the string R can be formed using only the characters from the substring of S. Since the number of ways can be very large, print the result modulo 998244353.

Function description

Complete the function solve() provided in the editor. This function takes the following 7 parameters and returns the required answer:

  • N: Represents the length of string S.
  • M: Represents the length of string R.
  • S: Represents the string S.
  • R: Represents the string R.
  • Q: Represents the number of queries.
  • X: Represents the starting position of substrings for each of the Q queries.
  • Y: Represents the ending position of substrings for each of the Q queries.

 

ADD COMMENTlink 4 days ago Sarthak • 0

Login before adding your answer.

Similar Posts
Loading Similar Posts