Questions: 5 831

Answers by our Experts: 5 728

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

Given a sentence as input, print all the unique combinations of two words in lexicographical order.Input


The input will be a single line containing a sentence.Output


The output should be multiple lines, each line containing the unique combination of two words in lexicographical order.Explanation


For example, if the given sentence is "raju plays cricket", the possible unique combination of two are (cricket, plays), (cricket, raju), (plays, raju). So the output should be

cricket plays
cricket raju
plays raju

Sample Input 1

raju plays cricket

Sample Output 1

cricket plays

cricket raju

plays raju

Sample Input 2

python is a programming language

Sample Output 2

a is

a language

a programming

a python

is language

is programming

is python

language programming

language python

programming python





Area of Largest Rectangle in Histogram

Given an list of integer 

heights representing the histogram's bar height where the width of each bar is 1, return the area of the largest rectangle in the histogram.

Input

The input will be a single line containing space-separated integers, denoting the heights of the bars.

Output

The output should be a single line containing the area of the largest rectangle in the rectangle.

Explanation

For example, if the given list of numbers are 

2 1 5 6 2 3 , when they are drawn adjacent to each other according to their heights, the histogram will be like

The largest rectangle can be found in between 5 and 6, which is 10.

Sample Input 1
2 1 5 6 2 3
Sample Output 1
10

Sample Input 2
65 87 96 31 32 86 57 69 20 42
Sample Output 2
248
Palindrome Pairs

Given a list of unique words, write a program to print all the pairs of the distinct indices (i, j) in the given list, so that the concatenation of two words at indices i and j is a palindrome.

Input

The input will be a single line containing a sentence.

Output

The output should be printing each distinct pair of indices (i, j) each in a line in ascending order.
If there are no distinct pairs found, print "-1"
Note: Consider (i, j) and (j, i) as two different pairs.

Explanation

For example, if the given sentence is

was it a car or a cat I saw

The words that can be concatenated to make a palindrome are

Words	Indices
(was, saw)	(0, 8)
(a, a)	(2, 5)
(a, a)	(5, 2)
(saw, was)	(8, 0)

So the output should be

0 8
2 5
5 2
8 0
Sample Input 1
was it a car or a cat I saw
Sample Output 1
0 8
2 5
5 2
8 0

Sample Input 2
bat tac tab cat
Sample Output 2
0 2
1 3
2 0
3 1

Write a program that reads a number and prints all of its binary digits: Print the remainder

number % 2, then replace the number with number / 2. Keep going until the number is 0. For 

example, if the user provides the input 13, the output should be

1


1

1


Secret Message - 1

Given a string, write a program to mirror characters of string in alphabetical order to create a secret message.




a b c d e f g h i j k l m

z y x w v u t s r q p o n 


n o p q r s t u v w x y z

m l k j i h g f e d c b a


Input


Input will be a string in the single line containing spaces and letters both uppercase and lowercase.


Output


Output should be a single line containing secret message. All characters in the output should be in lower case.


Explanation


For example, if given input is "python", "p" should replaced with "k", similarly "y" with "b", "t" with "g", "h" with "s", "o" with "l", "n" with "m". So output be "kbgslm".


Sample Input 1

python


Sample Output 1

kbgslm


Sample Input 2

Foundations


Sample Output 2

ulfmwzgrlmh


Given a MxN matrix,write a program to print all Anti-Diagonals elements of matrix

The first line of input will contain a M, N values separated by space.

The second line will contain matrix A of dimensions MxN.

The output should contain anti-diagonal elements separated by a line.

For example, if M = 4, N = 4

Matrix A:


Input :

2 3

1 5 5

2 7 8

Output must be

1

5 2

5 7

8


the output must be like this only without any extra messages


Numbers in String - 1


Given a string, write a program to return the sum and average of the digits of all numbers that appear in the string, ignoring all other characters.


Input


The input will be a single line containing a string.


Output


The output should contain the sum and average of the digits of all numbers that appear in the string.

Note: Round the average value to two decimal places.


Explanation


For example, if the given string is "I am 25 years and 10 months old", the digits of all numbers that appear in the string are 2, 5, 1, 0. Your code should print the sum of all digits(8) and the average of all digits(2.0) in the new line.


Sample Input 1

I am 25 years and 10 months old


Sample Output 1

8

2.0


Sample Input 2

Tech Foundation 35567


Sample Output 2

26

5.2


Sample input 3

Anjali25 is python4 Expert


Sample Output 3

11

3.67


Numbers in String - 1


Given a string, write a program to return the sum and average of the digits of all numbers that appear in the string, ignoring all other characters.


Input


The input will be a single line containing a string.


Output


The output should contain the sum and average of the digits of all numbers that appear in the string.

Note: Round the average value to two decimal places.


Explanation


For example, if the given string is "I am 25 years and 10 months old", the digits of all numbers that appear in the string are 2, 5, 1, 0. Your code should print the sum of all digits(8) and the average of all digits(2.0) in the new line.


Sample Input 1

I am 25 years and 10 months old


Sample Output 1

8

2.0


Sample Input 2

Tech Foundation 35567


Sample Output 2

26

5.2


Sample Input 3

1

output3

Anjali25 is python4 Expert




Ordered Matrix

Given a M x N matrix, write a program to print the matrix after ordering all the elements of the matrix in increasing order.


Input


The first line of input will contain two space-separated integers, denoting the M and N.

The next M following lines will contain N space-separated integers, denoting the elements of each list.


Output


The output should be M lines containing the ordered matrix.

Note: There is a space at the end of each line.


Explanation


For example, if the given M is 3 and N is 3, read the inputs in the next three lines if the numbers given in the next three lines are the following.

1 20 3
30 10 2
5 11 15


By ordering all the elements of the matrix in increasing order, the ordered matrix should be

1 2 3
5 10 11
15 20 30


Sample Input 1

3 3

1 20 3

30 10 2

5 11 15


Sample Output 1

1 2 3

5 10 11

15 20 30


Sample Input 2

2 5

-50 20 3 25 -20

88 17 38 72 -10


Sample Output 2

-50 -20 -10 3 17

20 25 38 72 88




IPL Match Details


Write a program that reads all match outcomes and summarizes information of all matches.

Points are given to teams based on outcome of match.

A win earns a team 3 points. A draw earns 1. A loss earns 0.

The following information is expected:

MP: Matches Played

W: Matches Won

D: Matches Drawn (Tied)

L: Matches Lost

P: Points


team information should be displayed in descending order of points.






If there are no teams to print in summary, print "No Output".


Constraints


Names of teams may contain spaces but will be less than 24 characters

100 >= N >= 0


Sample Input

6

CSK;RR;loss

RR;DD;draw

MI;KKR;win

KKR;RR;loss

CSK;DD;draw

MI;DD;draw


Sample Output

Team: RR, Matches Played: 3, Won: 2, Lost: 0, Draw: 1, Points: 7

Team: MI, Matches Played: 2, Won: 1, Lost: 0, Draw: 1, Points: 4

Team: DD, Matches Played: 3, Won: 0, Lost: 0, Draw: 3, Points: 3

Team: CSK, Matches Played: 2, Won: 0, Lost: 1, Draw: 1, Points: 1

Team: KKR, Matches Played: 2, Won: 0, Lost: 2, Draw: 0, Points: 0



LATEST TUTORIALS
APPROVED BY CLIENTS