Doubtly v2 is here : Register to experience
TCS NQT Previous Year Coding Test
Quizsummary
0 of 5 questions completed
Questions:
 1
 2
 3
 4
 5
Information
 This is a FREE online test.
 Total number of questions: 5
 Time allotted: 100 minutes.
 You Only Verify the Solution and Evaluate Yourself
 Doubtly does Not Process or evaluate Coding test
 Doubtly is not Affiliated with any companies mentioned in the Test
 DO NOT refresh the page.
 All the best!
You have already completed the quiz before. Hence you can not start it again.
Quiz is loading...
You must sign in or sign up to start the quiz.
You have to finish following quiz, to start this quiz:
Results
0 of 5 questions answered correctly
Your time:
Time has elapsed
You have reached 0 of 0 points, (0)
Categories
 Not categorized 0%
 1
 2
 3
 4
 5
 Answered
 Review

Question 1 of 5
1. Question
1 pointsGiven an array of integers where every element appears even number of times except one element which appears odd number of times, write a program to find that odd occurring element in O(log n) time. The equal elements must appear in pairs in the array but there cannot be more than two consecutive occurrences of an element.

For example :
3
2 3 2
It doesn't have equal elements appear in pairs
7
1 1 2 2 2 3 3
It contains three consecutive instances of an element.
5
2 2 3 1 1
It is valid and the odd occurring element present in it is 3.
Enter only valid inputs.
Sample Input :
5
2 2 3 1 1
Sample Output :
3 You can Use any IDE , I dont Care just make sure you try to solve on your own
Correct
Incorrect


Question 2 of 5
2. Question
1 pointsGiven an array of integers and a sum, the task is to count all subsets of given array with sum equal to given sum.

Input :
The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. Each test case contains an integer n denoting the size of the array. The next line contains n space separated integers forming the array. The last line contains the sum.
Output :
Count all the subsets of given array with sum equal to given sum.
NOTE: Since result can be very large, print the value modulo 109+7.
Constraints :
1<=T<=100
1<=n<=1031<=a[i]<=103
1<=sum<=103
Example :
Input :
2
6
2 3 5 6 8 10
10
5
1 2 3 4 5
10
Output :
3
3
Explanation :
Testcase 1: possible subsets : (2,3,5) , (2,8) and (10)
Testcase 2: possible subsets : (1,2,3,4) , (2,3,5) and (1,4,5)
You can Use any IDE , I dont Care just make sure you try to solve on your own
Correct
Incorrect


Question 3 of 5
3. Question
1 pointsBefore the outbreak of corona virus to the world, a meeting happened in a room in Wuhan. A person who attended that meeting had COVID19 and no one in the room knew about it! So everyone started shaking hands with everyone else in the room as a gesture of respect and after meeting unfortunately every one got infected! Given the fact that any two persons shake hand exactly once, Can you tell the total count of handshakes happened in that meeting?

Input Format :
The first line contains the number of test cases T, T lines follow.
Each line then contains an integer N, the total number of people attended that meeting.
Output Format :
Print the number of handshakes for each testcase in a new line.
Constraints :
1 <= T <= 1000
0 < N < 106
Sample Input :
2
1
2
Output :
0
1
Explanation :
Case 1 : The lonely board member shakes no hands, hence 0.
Case 2 : There are 2 board members, 1 handshake takes place.
You can Use any IDE , I dont Care just make sure you try to solve on your own
Correct
Incorrect


Question 4 of 5
4. Question
1 pointsFor enhancing the book reading, school distributed story books to students as part of the Children’s day celebrations. To increase the reading habit, the class teacher decided to exchange the books every weeks so that everyone will have a different book to read. She wants to know how many possible exchanges are possible.

If they have 4 books and students, the possible exchanges are 9. Bi is the book of ith student and after the exchange, he should get a different book, other than Bi.
B1 B2 B3 B4 – first state, before exchange of the books
B2 B1 B4 B3
B2 B3 B4 B1
B2 B4 B1 B3
B3 B1 B4 B2
B3 B4 B1 B2
B3 B4 B2 B1
B4 B1 B2 B3
B4 B3 B1 B2
B4 B3 B2 B1
Find the number of possible exchanges, if the books are exchanged so that every student will receive a different book.
Constraints
1<= N <= 1000000
Input Format
Input contains one line with N, indicates the number of books and number of students.
Output Format
Output the answer modulo 100000007.
Refer the sample output for formatting
Sample Input :
4
Sample Output :
9
You can Use any IDE , I dont Care just make sure you try to solve on your own
Correct
Incorrect


Question 5 of 5
5. Question
1 pointsYou are given a string A and you have to find the number of different substrings of the string A which are fake palindromes.

Note:
You can Use any IDE , I dont Care just make sure you try to solve on your own
1. Palindrome: A string is called a palindrome if you reverse the string yet the order of letters remains the same. For example, MADAM.
2. Fake Palindrome: A string is called as a fake palindrome if any of its permutations is a palindrome. For example, AAC is fake palindrome, but ACD is not.
3. Substring: A substring is a contiguous sequence (nonempty) of characters within a string.
4. Two substrings are considered same if their starting indices and ending indices are equal.
Input Format:
First line contains a string S
Output Format:
Print a single integer (number of fake palindrome substrings).
Constraints:
1 <= S <= 2 * 105
The string will contain only Upper case 'A' to 'Z'
Sample Input 1:
ABAB
Sample Output 1:
7
Explanation:
The fake palindrome for the string ABAB are A, B, A, B, ABA, BAB, ABAB.
Sample Input 2:
AAA
Sample output 2:
6
Explanation:
The fake palindrome for the string AAA are A, A, A, AA, AA, AAA
Correct
Incorrect
