TCS Digital Coding Problems
TCS Digital Coding Problems
Q1
Write a program to find the count of numbers which consists of unique digits.
Input:
Input consist of two Integer lower and upper value of an range
Output:
Output consists of single line, print the count of unique digits in given range. Else Print"No
Unique Number"
Solution:
Input -
10
15
Q2
There is a range given n and m in which we have to find the count all the prime pairs
whose difference is 6. We have to find how many sets are there within a given range.
Output:
Output consists of single line, print the count prime pairs in given range. Else print"No
Prime Pairs".
Constraints:
2<=n<=1000
n<=m<=2000
Sample Input:
4
30
Output:
6
Explanation:
(5, 11) (7, 13) (11, 17) (13, 19) (17, 23) (23, 29) . we have 6 prime pairs.
Solution:
Input -
101
500
Q3.
Write a program to print all the combinations of the given word with or without meaning
(when unique characters are given).
Sample Input:
abc
Output:
abc
acb
bac
bca
cba
cab
Solution:
Input -
hai
Q4.
Bastin once had trouble finding the numbers in a string. The numbers are distributed in
a string across various test cases. There are various numbers in each test case you
need to find the number in each test case. Each test case has various numbers in
sequence. You need to find only those numbers which do not contain 9. For eg, if the
string contains "hello this is alpha 5051 and 9475".You will extract 5051 and not 9475.
You need only those numbers which are consecutive and you need to help him find the
numbers. Print the largest number.
Note: Use long long for storing the numbers from the string.
Input:
The first line consists of T test cases and next T lines contain a string.
Output:
For each string output the number stored in that string if various numbers are there print
the largest one. If a string has no numbers print -1.
Constraints:
1<=T<=100
1<=|S|<=10000
Example:
Input:
1
This is alpha 5057 and 97
Output:
5057
Solution:
Input -
1
dream job 100 and 101