Without Ans
Without Ans
Without Ans
EG:
A=[1,2,7,0,5]
B=[ 9,1,9,9]
O/P
C=[3,5,0,6]
2. Find whether the give number is cool or not. The number is cool if sum of any digits is equal
to sum of other digits.
Eg:
1. Write a program to find the occurrence of the pattern string in the given string, such as
“THIS IS A GOOD COMPANY” is the given string, “IS” is the pattern string. Now the
number of occurrences is 2. (6 marks)
2. Finding the maximum subsequent sum in the array containing positive and negative numbers.
3. Checking if the two strings are anagrams.
Eg: Input: cat,act
Output: yes
4. Finding if one word is a rotation of another. The time complexity should be O(1). You can use
one function named indexOf(s1,s2) that returns 1 if s2 is a substring of s2 else return 0.
Eg: bose and sobe
3. We are given a set of integers with repeated occurences of elements. For Example,
S={1,2,2}.
We need to print the power set of S ensuring that the repeated elements of the power
set are printed only once.
For the above S, the power set will be {NULL, {1}, {2}, {2}, {1,2}, {1,2}, {2,2},
{1,2,2}}. So, as per the question requirements, we need to print {NULL, {1}, {2},
{1,2}, {2,2}, {1,2,2}}
4. Implement a BST (binary search tree) for the set of input values being given with the
first input being the root element. Display the tree-like structure.
1 8
0 3 7
5. One day Bob is playing Zombie World video game. In Zombie World game each
round will contain N zombie's and each zombie's energy is Zi (where 1<=i<=N). Bob
will start the round with B energy. In order to move to the next level Bob need to kill
all the N zombie's but Bob can select any one among N Zombie's. If energy of Bob
(B) is less than Zombie energy (Zi) then Bob will die and lose the round else Bob will
won, during the fighting with zombie, Bob will lose his energy by (Zi%2)+(Zi/2). At
any point of game Bob will play optimally. Now your task is to find out whether Bob
can reach to the next level or not.
6. . A k-palindrome is a string which transforms into a palindrome on removing atleast k
characters. Eg. Given a string S, print the palindrome string by removing k characters,
where k needs to be the minimum no. of characters that needs to be removed to get
the palindrome string.
ie. Input - abxa Output – aba / axa , k=1
Input - abdxa Output – aba / ada / axa , k=2
7. Find all possible longest increasing subsequences from an given array
Array 0 2 6 4 8 7
Ans :
Maxium length 4
0268
0248
0247
0267
Given a string , you have to predict whether it can be changed into a palindrome or not by
changing the positions of the characters
Eg. Tests
Yes
Explanation:tests can be changed to tsest or stets
19. How to find the second largest number in an array???(using single for loop or through
single traversal)
20. In a given string you should have the count of no of a,e,i,o,u and others(For eg: I AM
SAM
A:2,E:0,I:1,O:0,U:0,others:5(including spaces)).And print them as follows
A:2,E:0,I:1,O:0,U:0,others:5
39. 2 to 10 strings will be given consisting of alphabets and numbers, find the longest possible
palindrome in the ascending alphabetical (numbers first and then letters) order using characters
from all the given strings
40. The digital root (also called repeated digital sum ) of a number is a single
digit
value obtained by an iterative process of summing digits. Digital sum of 65536
is
7, because 6+5+5+3+6=25 and 2+5 = 7. Write a program that takes an integer
as input and prints its digital root.
41. ur program must print the following output if the input was ‘D’. Analyse
the
pattern and write a program to print the right output for any such char as input
A
ABA
ABCBA
ABCDCBA
ABCBA
ABA
A
42. Write a function which takes an array as input and produces another array
as
output. The function should do the product of all elements in the array with the
exception of the element with the current index.
the sum of the diagonal elements is 25.. if we have n*n or 1001*1001 then
what is the sum.
for the above same we have a question to print like this
7 8 9 2 1 6 5 4 3
1 6 7 8 9 2 3 4 5
48. *question 2*
0,1,2
49. *question 3*
1
89 98
101 103 106
trace the maximum summation path.. show it.. you can move only downwards....
50. *question 4*
1234
5678
9 10 11 12
13 14 15 18
51.
trace the highest summantion path.. you can move down and right...
52. *question 5*
viswa prasath
prabhu ram
ram viswa
o/p will be
viswa prasath - ram viswa
prabhu ram - ram viswa
if the first name of one name is equal to second name of another name then
print them..
56.*question 6*
n=4
most a is this flower beautiful...
*question 7*
139534795325345792
find its largest prime factor...
*question 8*
an integer array will be given.. have to find unique number of instance...
*question 9*
simulation election systems
*question 10*
check whether a string has a posibility for panlindrome or not...
61.
*From Mepco*
1. You are given with few anagrams. You have to split them into anagram
sets and others.
Eg: tar, rat, atr, banana, ananab, abcd
Ans : Anagrams - rat,tar,atr,ananab,banana
Others - abcd
2. Find the maximum sum of given series. Keep in mind that maximum sum
should be series.
Eg: -8,12,15,1,-10
Ans : 20 (-8+12+15+1)
3. You are given with a string. Find the character count. It is case
sensitive. Atlast delete the characters with maximum count.
Eg: abc Abc aac
Ans :
a3
b2
c2
A1
Stage 2:
ARRAY MANIPULATION
This stage is based on Array manipulations
eg 1:
Given an array shift it based on the start and the shift value.
Shift in general is shift right
Sample input:
Array: 5 10 15 20 25 30
Start : 2
Shift : 2
Output:
5 20 15 30 25 0
Stage 3:
STRING (PALINDROME)
1. Checking whether the given string(i.e only one word without spaces) is
palindrome.
2. Finding the substring given string ,start index and end index.
3. Finding the palindromes in a given sentence.
4. Finding the largest substring palindrome in a given word.
5. Finding the largest substring palindrome in a given sentence (ie
including spaces) If 2 palindrome have the same length then print both in
the order present in the input sentence.
6. Splitting the given word as following
-> INPUT:
amadamkak123
Output:
a-madam-kak-123
-> INPUT:
palindrome
Output:
p-a-l-I-n-d-r-o-m-e.
1) Provide two command line arguments i.e., two strings and check if second one is a substring of
the first string and * can used as a wildcard i.e., it can be substituted for any character. *
following any / can’t be used as a substitution.
Input : abcd,a*c => true
spoon,sp*n =>true
spoo,s*n =>false
zoho, *ogo=>false
india, *n*a=>true
sandy, s/*ndy =>false
2) Given a date and also number of business days in a week. Get the number of business days to
be added to the date and display the output. Number of business days in a week can be 5(i.e,
Saturday and Sunday holiday) or 6(i.e, Sunday only).
Input: 24th June,2015
Number of business days: 5
Business days to be added: 10
Output: 7th July,2015
Input: 7th September,1994
Number of business days: 6
Business days to be added:4
Output: 12th September,1994
3) Create a data structure to display the median in a given set of numbers.
Sample input: 2, 3,4,5,6 Sample output: median = 4
Sample input: 2, 3, 4,6,7,8 Sample output: median = ((4+6)/2)
4) Display the first unique element in a given array that contains both unique
and duplicate elements.
Sample input: ff, tt, ff, ch, tt, gh
Sample output: ch
8. Subtraction of long integers in array.consider two array A and B subtract A from B and store
the result in new array C
EG:
A=[1,2,7,0,5]
B=[ 9,1,9,9]
O/P
C=[3,5,0,6]
9. Find whether the give number is cool or not. The number is cool if sum of any digits is equal
to sum of other digits.
Eg:
5. Write a program to find the occurrence of the pattern string in the given string, such as
“THIS IS A GOOD COMPANY” is the given string, “IS” is the pattern string. Now the
number of occurrences is 2. (6 marks)
6. Finding the maximum subsequent sum in the array containing positive and negative numbers.
7. Checking if the two strings are anagrams.
Eg: Input: cat,act
Output: yes
8. Finding if one word is a rotation of another. The time complexity should be O(1). You can use
one function named indexOf(s1,s2) that returns 1 if s2 is a substring of s2 else return 0.
Eg: bose and sobe
10. We are given a set of integers with repeated occurences of elements. For Example,
S={1,2,2}.
We need to print the power set of S ensuring that the repeated elements of the power
set are printed only once.
For the above S, the power set will be {NULL, {1}, {2}, {2}, {1,2}, {1,2}, {2,2},
{1,2,2}}. So, as per the question requirements, we need to print {NULL, {1}, {2},
{1,2}, {2,2}, {1,2,2}}
11. Implement a BST (binary search tree) for the set of input values being given with the
first input being the root element. Display the tree-like structure.
2 8
0 3 7
12. One day Bob is playing Zombie World video game. In Zombie World game each
round will contain N zombie's and each zombie's energy is Zi (where 1<=i<=N). Bob
will start the round with B energy. In order to move to the next level Bob need to kill
all the N zombie's but Bob can select any one among N Zombie's. If energy of Bob
(B) is less than Zombie energy (Zi) then Bob will die and lose the round else Bob will
won, during the fighting with zombie, Bob will lose his energy by (Zi%2)+(Zi/2). At
any point of game Bob will play optimally. Now your task is to find out whether Bob
can reach to the next level or not.
13. . A k-palindrome is a string which transforms into a palindrome on removing atleast k
characters. Eg. Given a string S, print the palindrome string by removing k characters,
where k needs to be the minimum no. of characters that needs to be removed to get
the palindrome string.
ie. Input - abxa Output – aba / axa , k=1
Input - abdxa Output – aba / ada / axa , k=2
14. Find all possible longest increasing subsequences from an given array
Array 0 2 6 4 8 7
Ans :
Maxium length 4
0268
0248
0247
0267
Given a string , you have to predict whether it can be changed into a palindrome or not by
changing the positions of the characters
Eg. Tests
Yes
Explanation:tests can be changed to tsest or stets
29. How to find the second largest number in an array???(using single for loop or through
single traversal)
30. In a given string you should have the count of no of a,e,i,o,u and others(For eg: I AM
SAM
A:2,E:0,I:1,O:0,U:0,others:5(including spaces)).And print them as follows
A:2,E:0,I:1,O:0,U:0,others:5
39. 2 to 10 strings will be given consisting of alphabets and numbers, find the longest possible
palindrome in the ascending alphabetical (numbers first and then letters) order using characters
from all the given strings
40. The digital root (also called repeated digital sum ) of a number is a single
digit
value obtained by an iterative process of summing digits. Digital sum of 65536
is
7, because 6+5+5+3+6=25 and 2+5 = 7. Write a program that takes an integer
as input and prints its digital root.
41. ur program must print the following output if the input was ‘D’. Analyse
the
pattern and write a program to print the right output for any such char as input
A
ABA
ABCBA
ABCDCBA
ABCBA
ABA
A
42. Write a function which takes an array as input and produces another array
as
output. The function should do the product of all elements in the array with the
exception of the element with the current index.
the sum of the diagonal elements is 25.. if we have n*n or 1001*1001 then
what is the sum.
1 6 7 8 9 2 3 4 5
48. *question 2*
0,1,2
49. *question 3*
1
89 98
101 103 106
trace the maximum summation path.. show it.. you can move only downwards....
50. *question 4*
1234
5678
9 10 11 12
13 14 15 18
51.
trace the highest summantion path.. you can move down and right...
52. *question 5*
viswa prasath
prabhu ram
ram viswa
o/p will be
viswa prasath - ram viswa
prabhu ram - ram viswa
if the first name of one name is equal to second name of another name then
print them..
56.*question 6*
*question 7*
139534795325345792
find its largest prime factor...
*question 8*
an integer array will be given.. have to find unique number of instance...
*question 9*
simulation election systems
*question 10*
check whether a string has a posibility for panlindrome or not...
61.
*From Mepco*
1. You are given with few anagrams. You have to split them into anagram
sets and others.
Eg: tar, rat, atr, banana, ananab, abcd
Ans : Anagrams - rat,tar,atr,ananab,banana
Others - abcd
2. Find the maximum sum of given series. Keep in mind that maximum sum
should be series.
Eg: -8,12,15,1,-10
Ans : 20 (-8+12+15+1)
3. You are given with a string. Find the character count. It is case
sensitive. Atlast delete the characters with maximum count.
Eg: abc Abc aac
Ans :
a3
b2
c2
A1
Stage 2:
ARRAY MANIPULATION
This stage is based on Array manipulations
eg 1:
Given an array shift it based on the start and the shift value.
Shift in general is shift right
Sample input:
Array: 5 10 15 20 25 30
Start : 2
Shift : 2
Output:
5 20 15 30 25 0
Stage 3:
STRING (PALINDROME)
1. Checking whether the given string(i.e only one word without spaces) is
palindrome.
2. Finding the substring given string ,start index and end index.
3. Finding the palindromes in a given sentence.
4. Finding the largest substring palindrome in a given word.
5. Finding the largest substring palindrome in a given sentence (ie
including spaces) If 2 palindrome have the same length then print both in
the order present in the input sentence.
6. Splitting the given word as following
-> INPUT:
amadamkak123
Output:
a-madam-kak-123
-> INPUT:
palindrome
Output:
p-a-l-I-n-d-r-o-m-e.
5) Provide two command line arguments i.e., two strings and check if second one is a substring of
the first string and * can used as a wildcard i.e., it can be substituted for any character. *
following any / can’t be used as a substitution.
Input : abcd,a*c => true
spoon,sp*n =>true
spoo,s*n =>false
zoho, *ogo=>false
india, *n*a=>true
sandy, s/*ndy =>false
6) Given a date and also number of business days in a week. Get the number of business days to
be added to the date and display the output. Number of business days in a week can be 5(i.e,
Saturday and Sunday holiday) or 6(i.e, Sunday only).
Input: 24th June,2015
Number of business days: 5
Business days to be added: 10
Output: 7th July,2015
Input: 7th September,1994
Number of business days: 6
Business days to be added:4
Output: 12th September,1994
7) Create a data structure to display the median in a given set of numbers.
Sample input: 2, 3,4,5,6 Sample output: median = 4
Sample input: 2, 3, 4,6,7,8 Sample output: median = ((4+6)/2)
8) Display the first unique element in a given array that contains both unique
and duplicate elements.
Sample input: ff, tt, ff, ch, tt, gh
Sample output: ch