0% found this document useful (0 votes)
123 views2 pages

Sno - Input Output

The first document describes sorting words and numbers from a text input in ascending order, converting words to lowercase, and printing each word followed by a number. The second document lists 3 problems - finding the lowest frequency character in a string, finding the first occurrence of a word in a string, and converting a number string to an integer. The third document defines finding the common stem from a list of words by finding the longest common substring that occurs in all words, with ties broken by alphabetical order.

Uploaded by

Pawan Nani
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)
123 views2 pages

Sno - Input Output

The first document describes sorting words and numbers from a text input in ascending order, converting words to lowercase, and printing each word followed by a number. The second document lists 3 problems - finding the lowest frequency character in a string, finding the first occurrence of a word in a string, and converting a number string to an integer. The third document defines finding the common stem from a list of words by finding the longest common substring that occurs in all words, with ties broken by alphabetical order.

Uploaded by

Pawan Nani
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/ 2

1.

Given text comprising of words and numbers, sort them both in ascending order and print
them in a manner that a word is followed by a number. Words can be in upper or lower case.
You have to convert them into lowercase and then sort and print them.
Input Format:

First line contains total number of test cases, denoted by N


Next N lines, each contains a text in which words are at odd position and numbers are
at even position and are delimited by space
Output Format:

Words and numbers sorted in ascending order and printed in a manner t hat a word is
followed by a number.
Constraints:
1. Text starts with a word
2. Count of words and numbers are the same.
3. Duplicate elements are not allowed 
4. Words should be printed in lower case. 
5. No special characters allowed in text.

SNo
Input Output
.

2
Sagar 35 sanjay 12 ganesh 12 ramesh 19
1
ganesH 53 ramesh 19 sagar 35 sanjay 53
Ganesh 59 suresh 19 ganesh 19 lalit 26
rakesh 26 laliT 96 rakesh 59 suresh 96
2.a) Find the lowest frequency character in a given string.

b)Write a program to find the first occurance of a word in a given string.

c) Write a program to convert a number read as a string into an integer.


3. Given n words w[1..n], which originate from the same stem (e.g.
grace,graceful,disgraceful,gracefully), we are interested in the original stem. To simplify the
problem, we define the stem as the longest consecutive substring that occurs in all the n words.
if there are ties, we will choose the smallest one in the alphabetical (lexicographic) order.

INPUT

grace graceful disgraceful gracefully

grace

You might also like