0% found this document useful (0 votes)
31 views4 pages

Nakuri Challenge

nakuri challenge

Uploaded by

Selvakumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views4 pages

Nakuri Challenge

nakuri challenge

Uploaded by

Selvakumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Coding

Description
Problem Statement
As we all know, Tan is fond of string as well as of Taru. So, he decided to gift a
string to Taru as Valentine's Gift. Since Tan is a student, he went to a gift store and
asked for the required string. The shopkeeper gives her an integer denoting the
number of strings that satisfy his condition.
Since Tan is busy, he forgets the number of options that the shopkeeper has given
to him. He needs your help to get the number of options so that he can choose the
string.
The condition of valid strings are -:
 The string size should be exactly N.
 The string will only contain characters which are (T, A, R, U, N, S)
 It should start with 'T', 'N' or 'S' only.
 After every 'T' there comes 'A' only.
 After every 'R' there comes 'U' only.
 After every 'N' there comes 'R' only.
 After every 'A' there comes either 'N' or 'R' only.
 After every 'U', there comes 'S' only.
 After every 'S', there may come any character (i.e. 'T', 'A', 'N', 'R', 'U').
 No character should be followed by the same character.
You are given an integer n, denoting the size of string which Tan wants, you have
to return an integer, the number of string satisfying the above conditions.
Since the answer may be too large, return it modulo 109+7.
Input Format
 The first and only line will contain an integer N, the size of the string which Tan wants.
Constraints
 1 ≤ N ≤ 2 * 104
Output Format
 Return a single integer denoting the number of valid strings of length N which can be
formed by following the above constraints.
Evaluation Parameters
 Sample Input
2

 Sample Output
7

 Explanation
Valid strings of length 2 are - { TA, NR, ST, SA, SN, SR, SU };

Coding
Description
You are given 3 integers: N, K, and X, where N denotes the size of the array.
Your task is to find the number of possible arrays such that the first element is 1
and the last element is X, and all the other elements should be between 1 and K,
both inclusive, and no two consecutive elements should be the same.
As the answer can be large, you have to print the answer modulo 1000000007.
Input
 The first three lines contain 3 positive integers denoting the values of N, K, and X.
Output
 Return the answer modulo 1000000007.
Constraints
 3<= N <=100000
 2<= K <=100000
 1<= X <= K
Sample Test Case
Input
4

Output
3
Explanation
possible arrays are
{1,3,1,2}
{1,2,1,2}
{1,2,3,2}
Execution time limit
Default

Description
Problem Statement
Sam likes making sweets. He can make n different types of sweets. A sweet is
defined by two things, first Ai which denotes the time it takes to make the i-th
sweet, and Bi the sweetness level of the i-th sweet. But Sam is also a busy person,
and he has only m days with him and on a given day he can devote at
maximum Cj time on the j-th day. Help him decide how many sweets he can make
while maximizing the total sweetness of all the sweets taken together and the
number of sweets made. Note: He can make the i-th type of sweet only once and at
most only one sweet per day.
Input Format
 The first line contains n the different types of sweet
 The next n lines contain the elements of array A.
 The next line again contains n.
 After it, the next n lines contain the elements of array B.
 The next line contains m, the number of days he has with him to prepare sweets.
 The next m lines contain the elements of array C

Constraints
 1 <= n, m, Ai, Bi, Ci <= 105

Output Format
 Return an array containing two elements where its first element contains the maximum number of
sweets he should make and the second element contains the maximum number of the sweetness of all
the sweets taken together that he should make.

Evaluation Parameters
 Sample Input
3

10
2

40

90

20

 Sample Output
2

110

 Explanation

He can choose to make the second type of sweet on day 3 and the third type of
sweet on day 3. Thus he makes 2 sweets and the total sweetness of them is 110
which is the maximum possible here.
Execution time limit
Default

Report an issue

You might also like