Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search & Filtering

Triplet Sum

Given an array n integers, find and print all the unique triplets (a, b, c) in the array which give the sum K. (a+b+c=K).Input


The first line of the input will be space separated integers, denoting the elements of the array. The second line of the input will be an integer denoting the required sum KOutput


The output should be multiple lines, each line containing a unique triplet. The elements of the triple must be sorted in increasing order and all the triplets printed must be sorted in increasing order. Print "No Matching Triplets Found" if there are no triplets with the given sum.Explanation


When the given array is [0, 1, 2, 3, 5, 7, 13, 17, 19, 19] and the required sum is 22, the triplets (0, 3, 19), (0, 5, 17), (1, 2, 19), (2, 3, 17) and (2, 7, 13) have the given sum 22.

Sample Input 1

0 12 17 8 9 21

29

Sample Output 1

(0, 8, 21)

(0, 12, 17)

(8, 9, 12)

Sample Input 2

0 1 2 3 5 7 13 17 19 19

22

Sample Output 2

(0, 3, 19)

(0, 5, 17)

(1, 2, 19)

(2, 3, 17)

(2, 7, 13)




Non-Adjacent Combinations of Two Words

Given a sentence as input, find all the unique combinations of two words and print the word combinations that are not adjacent in the original sentence in lexicographical order.Input


The input will be a single line containing a sentence


The output should be multiple lines, each line containing a valid unique combination of two words. The words in each line should be lexicographical order and the lines as well should be in lexicographical order. A valid combination will not contain the words that appear adjacent in the given sentence. Print "No Combinations" if there are no valid combinations


programming python

Sample Input 1

raju always plays cricket

Sample Output 1

always cricket

cricket raju

plays raju

Sample Input 2

python is a programming language

Sample Output 2

a language

a python

is language

is programming

language python

programming python

Sample Input 3

to be or not to be

Sample Output 3

be be

be not

or to

to to




Define a class string. Use different constructors and do the following [20 marks]

 - Create un-initialized string objects

 - Create objects with string constants

 - Concatenate two strings

 - Display desired strings


Given a matrix of order M*N and a value K, write a program to rotate each ring of the matrix clockwise by K elements. If in any ring has less than or equal to K elements, then don’t rotate that ring.
Input

The first line of input will be two space-separated integers, denoting the M and N.
The next M lines will contain N space-separated integers.
The next line will contain an integer, denoting K.
Output

If the given K is 3. Rotate each ring of the matrix by 3 elements.
In the above matrix, the elements (1, 2, 3, 4, 8, 12, 16, 15, 14, 13, 9, 5) is a ring, similarly, the elements (6, 7, 11, 10) will make a ring.
Therefore, by rotating each ring in clockwise direction by 3 elements will give (13, 9, 5, 1, 2, 3, 4, 8, 12, 16, 15, 14) and (10, 6, 7, 11). So the output should be 
13 9 5 1
14 7 11 2
15 6 10 3
16 12 8 4
Sample Input 1
4 4
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
3

Sample Output 1
13 9 5 1
14 7 11 2
15 6 10 3
16 12 8 4

Sample Input 2
3 4
1 2 3 4
10 11 12 5
9 8 7 6
2
Sample Output 2
9 10 1 2
8 11 12 3
7 6 5 4









Rearrange Numbers in String


Given a string, write a program to re-arrange all the numbers appearing in the string in decreasing order. Note: There will not be any negative numbers or numbers with the decimal part.



Input

The input will be a single line containing a string.



Output

The output should be a single line containing the modified string with all the numbers in the string re-ordered in decreasing order.



Explanation

For example, if the given string is "I am 5 years and 11 months old", the numbers are 5, 11. Your code should print the sentence after re-ordering the numbers as "I am 11 years and 5 months old".


Sample Input

I am 5 years and 11 months old


Sample Output

I am 11 years and 5 months old


Sample Input

I am 17 I want 18 but 20or24 ok


Sample Output

I am 24 I want 20 but 18or17 ok



Sample Input

I have learnt 3% of Python 4 for 45 days


Sample Output

I have learnt 45% of Python 4 for 3 days


class a class vehicle with erg_no and cost as data members and define virtual functions start(),stop() show(). Write a complete program having derived classes such as heavy, Lightweight vehicle etc.


Suppose that one of the largest commercial bank branch in UAE has recently experienced a significant distress due to covid 19. A huge No. of account holders withdraws the payment from the bank. Now manager want to check the total number of accounts those have less than 1000$.

You are required perform the following task:

Write only Pseudocode to check the total number of accounts, who have less than 1000$ using array list


You are given a square matrix A of dimensions NxN. You need to apply the below given 3 operations on the matrix A.


Rotation: It is represented as R S where S is an integer in {90, 180, 270, 360, 450, ...} which denotes the number of degrees to rotate. You need to rotate the matrix A by angle S in the clockwise direction. The angle of rotation(S) will always be in multiples of 90 degrees.


Update: It is represented as U X Y Z. In initial matrix A (as given in input), you need to update the element at row index X and column index Y with value Z.

After the update, all the previous rotation operations have to be applied to the updated initial matrix.


Querying: It is represented as Q K L. You need to print the value at row index K and column index L of the matrix A.


Complete the sentence about the word Reaction.

A reaction is when...


Rearrange Numbers in String


Given a string, write a program to re-arrange all the numbers appearing in the string in decreasing order. Note: There will not be any negative numbers or numbers with decimal part.


Input

The input will be a single line containing a string.


Output

The output should be a single line containing the modified string with all the numbers in string re-ordered in decreasing order.


Explanation

For example, if the given string is "I am 5 years and 11 months old", the numbers are 5, 11. Your code should print the sentence after re-ordering the numbers as "I am 11 years and 5 months old".


Sample Input

I am 5 years and 11 months old


Sample Output

I am 11 years and 5 months old



Sample Input

I have learnt 3% of Python 4 for 45 days


Sample Output

I have learnt 45% of Python 4 for 3 days


LATEST TUTORIALS
APPROVED BY CLIENTS