Hello folks.....!!!
Try these questions in your editor. All the questions below are placement questions. Try them in optimal way.
Q1. Given a string s,recursively remove adjacent duplicate characters from the string s. The output string should not have any adjacent duplicates.
example 1: aabbabcdeddf
steps:
Remove aa - as they occur together - now we have bbabcdeddf
Remove bb - now we get abcdeddf
Then remove dd - we get abcdef and there are no more repetition.
Final answer is abcdef.
example 2: azxxzy
First remove xx - we get azzy
Remove zz - we get ay
Final answer is ay.
Q2. Given two strings a and b, the task is to find if the string a can be obtained by rotating the another string b to its left 2 times. If the preceding case is true , print "yes" otherwise "no".
example :
a= thonpy
b= python
If the string b is rotated to its left twice, we get ythonp on first rotation and then thonpy on second rotation. The string a and b are equal now. So print yes.
Find the output for the following :
1. a=bdghabdaaa b=aabdghabda
2. a=tefliesik b=kiteflies
Q3. Given a string s,the task is to print all the permutations of a given string.
eg : input: abc
answer : abc, acb, bac, bca, cba, cab
Find the output for the following :
1. dvbb
2. keen
Comments
Post a Comment