You are on page 1of 5

1. Vinay decides to solve at least 10 problems every week for 4 weeks.

Given the number of problems he actually solved in each week over 4 weeks as P1, P2, P3
, and P4, output the number of weeks in which Vinay met his target.

Input Format

There is a single line of input, with 4 integers P1, P2, P3, and P4. These are the number of
problems solved by Vinay in each of the 4 weeks.

Output Format

Output a single integer in a single line - the number of weeks in which Vinay solved at
least 10 problems.

2. Given a list of N contest codes, where each contest code is either START38 or LTIME108,
help Vinay count how many problems were featured in each of the contests.

Input Format

• First line will contain T, number of test cases. Then the test cases follow.
• Each test case contains of two lines of input.
• First line of input contains the total count of problems that appeared in the two
recent contests - N.
• Second line of input contains the list of N contest codes. Each code is
either START38 or LTIME108, to which each problem belongs.

Output Format

• For each test case, output two integers in a single new line - the first integer should
be the number of problems in START38, and the second integer should be the
number of problems in LTIME108.

Input:

3
START38 LTIME108 START38

4
LTIME108 LTIME108 LTIME108 START38

2
LTIME108 LTIME108

6
START38 LTIME108 LTIME108 LTIME108 START38 LTIME108

Output:

2 1
1 3
0 2
2 4

Explanation:

Test case 1: There are 2 START38 in the input, which means that there were 2 problems
in START38. Similarly, there was 1 problem in LTIME108.
Test case 2: There is 1 START38 in the input, which means that there was 1 problem
in START38. Similarly, there were 3 problems in LTIME108.
Test case 3: There are no START38 in the input, which means that were 0 problems
in START38. Similarly, there were 2 problems in LTIME108.
Test case 4: There are 2 START38 in the input, which means that there were 2 problems
in START38. Similarly, there were 4 problems in LTIME108.

3. Ajay likes the number 2, 3, 9. Therefore, he considers a number pretty if its last digit
is 2, 3 or 9.
Ajay wants to watch the numbers between L and R (both inclusive), so he asked you to
determine how many pretty numbers are in this range. Can you help him?

Input

• The first line of the input contains a single integer T denoting the number of test
cases. The description of T test cases follows.
• The first and only line of each test case contains two space-separated
integers L and R.

Output

• For each test case, print a single line containing one integer — the number of pretty
numbers between L and R.

Sample Input:

2
1 10
11 33

Sample Output:

3
8

Explanation:

Example case 1: The pretty numbers between 1 and 10 are 2, 3 and 9.


Example case 2: The pretty numbers
between 11 and 33 are 12, 13, 19, 22, 23, 29, 32 and 33.

4. Chef usually likes to play cricket, but now, he is bored of playing it too much, so he is
trying new games with strings. Chef's friend Dustin gave him binary strings S and R, each
with length N, and told him to make them identical. However, unlike Dustin, Chef does not
have any superpower and Dustin lets Chef perform only operations of one type: choose any
pair of integers (i, j) such that 1≤i, j ≤N and swap the i-th and j-th character of S. He may
perform any number of operations (including zero).
For Chef, this is much harder than cricket and he is asking for your help. Tell him whether
it is possible to change the string S to the target string R only using operations of the given
type.

Input

• The first line of the input contains a single integer T denoting the number of test
cases. The description of T test cases follows.
• The first line of each test case contains a single integer N.
• The second line contains a binary string S.
• The third line contains a binary string R.

Output

• For each test case, print a single line containing the string "YES" if it is possible to
change S to R or "NO" if it is impossible.
Sample Input:

5
11000
01001

3
110
001

Sample Output:

YES
NO

5. Alice and Bob went to a pet store. There are N animals in the store where the ith animal
is of type Ai.
Alice decides to buy some of these N animals. Bob decides that he will buy all the
animals left in the store after Alice has made the purchase.
Find out whether it is possible that Alice and Bob end up with exactly same multiset of
animals.

Input Format

• The first line of input will contain a single integer T, denoting the number of test
cases.
• Each test case consists of multiple lines of input.
o The first line of each test case contains an integer N — the number of animals in
the store.
o The next line contains N space separated integers, denoting the type of each
animal.

Output Format

• For each test case, output on a new line, YES, if it is possible that Alice and Bob end
up with exactly same multiset of animals and NO otherwise.

Input:

3
444
4
2332

4
1223

6
551515

Output:

NO
YES
NO
YES

Explanation:

Test case 1: There are 4 possible cases:


• Alice does not buy anything: Bob will buy all the animals and will have 3 animals of
type 4.
• Alice buys 1 animal of type 4: Bob will buy the remaining two animals of type 4.
• Alice buys 2 animals of type 4: Bob will buy the remaining one animal of type 4.
• Alice buys all 3 animals of type 4: Bob will not buy anything.

In no case, both Alice and Bob can have the exactly same multiset of pets.

Test case 2: If Alice buys animals 1 and 2, having types 2 and 3 respectively, Bob will buy
animals 3 and 4, having types 3 and 2 respectively. Thus, both Alice and Bob have 1 animal
of type 2 and 1 animal of type 3.
Test case 3: It can be proven that Alice and Bob cannot have the same multiset of pets in
any case.
Test case 4: If Alice buys animals 1,2, and 5, having types 5,5 and 1 respectively, Bob will
buy animals 3, 4 and 6, having types 1,5 and 5 respectively. Thus, both Alice and Bob
have 1 animal of type 1 and 2 animals of type 5.

You might also like