[go: up one dir, main page]

0% found this document useful (0 votes)
44 views16 pages

Sri Krishna-Strings

The document outlines a series of programming tasks related to string manipulation, including ticket number filtering, frequency counting of characters, identifying non-repeating characters, reversing words, custom sorting based on keys, finding the smallest missing character, calculating word averages, encrypting strings, checking subsequences, and determining anagrams. Each task includes input and output formats along with examples to clarify the requirements. The tasks are designed to test various string processing skills in programming.

Uploaded by

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

Sri Krishna-Strings

The document outlines a series of programming tasks related to string manipulation, including ticket number filtering, frequency counting of characters, identifying non-repeating characters, reversing words, custom sorting based on keys, finding the smallest missing character, calculating word averages, encrypting strings, checking subsequences, and determining anagrams. Each task includes input and output formats along with examples to clarify the requirements. The tasks are designed to test various string processing skills in programming.

Uploaded by

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

1.

An event management company has come up with a


unique idea of printing their event tickets. Based on the
ticket number combination (str1), the visitor is directed
towards a particular class of audience. The task is to
create a program/application to fetch the ticket number
based on the following conditions:

Any occurrences of digits EF and G should be deleted.


The characters EF should be in the same format.

Input format
The candidate has to write the code to accept 1 input(s).
First Input -Accept value for str1 which is a string
consisting of numbers and uppercase alphabets without
any spaces
The output should be a string without any spaces (Check
the output in Example 1 and Example 2) Additional
messages in output will cause the failure of test cases.

Constraints
Str ((A,Z),(0-9))
No spaces and special characters allowed.
Only uppercase alphabets in the input string

Example 1:

Input:

4523EF58G -> A value of STR1


Output :
452358 -> A after removal of characters EF and G

Example 2:

Input:
E12F35G58 -> A value of STR1

Output :
E12F3558 -> A after removal of characters “G”

Explanation:
In the above example, characters E and F are not
together So, they won't be deleted. The output will be
with only character G removed.
question
2.Given a string in which the same character occurs in
many consecutive character elements. Your task is to find
the characters that have even frequency and are
consecutive. Display the sum of every frequency
count( For even frequency only)
Example 1:
Sample Input:
aaabbaccccdd
Sample Output:
8

Example 2
Sample Input:
vdkkmmmnn
Sample Output:
4
3.Strings - First Non-repeating Character
question
Lee conducted a word game for his colleagues. The game is everyone
should say a word that should not have any repeating characters in it.
If a single character is repeated then the particular person can't
continue the game. Lee finds it difficult to disqualify the person from
the game since he is not able to find the nonrepetitive character for all
the words. Help him to find the winner of the game by writing a
program to find the first element which is non -repetitive i.e that
element must not be present anywhere else in the string.
Sample Input 0
teeterson
Sample Output 0
r
Explanation 0
Here in the word teeterson the first non-repeating character is r and
hence it prints r.
question
4. Strings - Reverse each word of a string

Sample Input:

Hello World

Sample Output

World Hello
question
5.Mike came up with a new way of sorting a string. What
he does is he takes all the unique alphabets from the
string and sorts it in that order. Let say there is a string
"apple", now it contains a p l e as distinct alphabets.

He sorts the string apple based on his own keys let say
eapl. So, first all "e" will be picked from the string
"apple", and then all "a", and so on till "T". Hence the
final sorted word becomes "eappl".

The Input format for testing


The candidate has to write the code to accept 2 input(s)
•First Input - Accept value for input string.
•First Input - Accept value for input key.

The Output format for testing


question
•The output should be a sorted string based on the input
key given by the user as mentioned in the above criteria.
(Check the output in Example 1, Example 2)

•Additional messages in output will cause the failure of


test cases.

Constraints:
0<length(input String)<=50
Input key should contain all the alphabets of inputstrings
No duplicates in input keys.

Example 1:
Input:
apple->Input string
eapl -> Input string, sorting key value
question
Output:
eappl->output string with sorted value based on the user
keys.

Explanation:
The input by the user is "apple” and the key is "eapl". So,
as per the key, all "e" has to be sorted first. Then all the
a's and the all the p's, and finally all the 1’s .Note that
here we have 2 p's so they will be sorted together in the
output. Putting everything together the final string comes
as “eappl”

Example 2:

Input:
welcome ->input string
question
6..Find Smallest Character
Problem Statement
You are given a function:
def SmallestCharacter(s):
The function accepts a string ‘s’. Implement the function
to find the smallest English character which is not
present in the given string ‘s’ and return the same.
question
Example :
Input :
aidubudxd
Output :
c
Explanation :
Input string contains a and b. So now the smallest
character that is not present in the string is c.
The custom input format for the above case:
aidubndxd
question
7. Find the word average
Problem Statement
Implement the following function:
Static float Average(String str){}
The function accepts a string ‘str’ of length ‘len’ as its
arugment. Implement the function to calculate the word
average and return the same. Word Average is calculated
by finding the average of the ASCII values of all of the
letters in a word.
question
Sample Input
Str: asp
Sample Output
108.00
The custom input format for the above case:
asp
(The first line represents the string ‘str’).
question
8. Strings – Encryption

Sample Input 0
39631

Sample Output 0
93361

Explanation 0
Step 1 - Interchange the first two digits, 3 and 9, which form 93631.
Step 2 - Interchange the third and fourth digits, 6 and 3 which form
93361, Step 3 - For the fifth digit as there is no digit to be interchanged
with, it is left it is so it will be kept as 93361. So, the output is 93361.
question
9. Strings - String Subsequence
Given two strings s and t, return 1 if s is a subsequence of t, or 0 otherwise.
A subsequence of a string is a new string that is formed from the original
string by deleting some (can be none) of the characters without disturbing the
relative positions of the remaining characters. (i.e., "abe" is a subsequence of
"abcde" while "aed" is not).
Sample Input 0
abcde
abe
Sample Output 0
1

Sample Input 0
bytexl
beyl
Sample Output 0
0
question
10. Strings - String Anagram

Write a program to find whether the given string is the anagram of the
first string.

Note: An anagram of a string is another string that contains the same


characters, only the order of characters can be different.

Sample Input 0
eat
ate

Sample Output 0
Anagram

You might also like