TCS CodeVita Questions | TCS CodeVita previous year questions
TCS CodeVita questions asked in previous TCS CodeVita seasons are discussed here. TCS CodeVita is a global coding contest and hence the level of questions is advanced. You need to be a pro at programming to crack TCS CodeVita.
Don't know about TCS CodeVita:- click here
Important topics/questions asked in TCS CodeVita coding questions:-
Here are some of the most asked concepts/questions in TCS CodeVita. Have a look at them and start solving now. You can practice these from websites like Hackerrank, Codechef, HackerEarth, and geeksforgeeks.
- Max Flow Problem
- Segment Trees
- Bit-masking DP
- Pattern matching and Pattern searching - Z algorithm, Rabin-Karp algorithm, KMP algorithm
- DFS and BFS
- Dijkstra, Kruskal
- Coin Sum
- Subset Sum
- Knapsack
- Min Cost Path
- DFS with memorization
- DFS in matrices
TCS CodeVita Questions (Previously asked)
Practicing the previous year TCS CodeVita questions will give you a better understanding of the standard of questions asked.
Q1. Consecutive Prime Sum
Some prime numbers can be expressed as a sum of other consecutive prime numbers. For example 5 = 2 + 3, 17 = 2 + 3 + 5 + 7, 41 = 2 + 3 + 5 + 7 + 11 + 13. Your task is to find out how many prime numbers which satisfy this property are present in the range 3 to N subject to a constraint that summation should always start with number 2.
Write code to find out the number of prime numbers that satisfy the above-mentioned property in a given range.
Q2. Bank Compare
There are two banks – Bank A and Bank B. Their interest rates vary. You have received offers from both banks in terms of the annual rate of interest, tenure, and variations of the rate of interest over the entire tenure. You have to choose the offer which costs you the least interest and rejects the other. Do the computation and make a wise choice.
The loan repayment happens at a monthly frequency and Equated Monthly Installment (EMI) is calculated using the formula given below :
EMI = loanAmount * monthlyInterestRate / ( 1 – 1 / (1 + monthlyInterestRate)^(numberOfYears * 12))
Constraints:
1 <= P <= 1000000
1 <=T <= 50
1<= N1 <= 30
1<= N2 <= 30
Input Format:
First line: P principal (Loan Amount)
Second line: T Total Tenure (in years).
Third Line: N1 is the number of slabs of interest rates for a given period by Bank A. First slab starts from the first year and the second slab starts from the end of the first slab and so on.
Next N1 line will contain the interest rate and their period.
After N1 lines we will receive N2 viz. the number of slabs offered by the second bank.
Next N2 lines are the number of slabs of interest rates for a given period by Bank B. The first slab starts from the first year and the second slab starts from the end of the first slab and so on.
The period and rate will be delimited by a single white space.
Output Format: Your decision either Bank A or Bank B.
Q3. Counting Rock Samples
Juan Marquinho is a geologist and he needs to count rock samples in order to send it to a chemical laboratory. He has a problem: The laboratory only accepts rock samples by a range of its size in ppm (parts per million).
Juan Marquinho receives the rock samples one by one and he classifies the rock samples according to the range of the laboratory. This process is very hard because the number of rock samples may be in millions.
Juan Marquinho needs your help, your task is to develop a program to get the number of rocks in each of the ranges accepted by the laboratory.
Input Format:
A positive integer S (the number of rock samples) separated by a blank space, and a positive integer R (the number of ranges of the laboratory); A list of the sizes of S samples (in ppm), as positive integers separated by space R lines where the ith line containing two positive integers, space-separated, indicating the minimum size and maximum size respectively of the ith range.
Output Format:
R lines where the ith line containing a single non-negative integer indicating the number of the samples which lie in the ith range.
Constraints: 10 ? S ? 10000 1 ? R ? 1000000 1?size of each sample (in ppm) ? 1000
Example:-
Input: 10 2
345 604 321 433 704 470 808 718 517 811
300 350
400 700
Q4. the kth largest factor of N
A positive integer d is said to be a factor of another positive integer N if when N is divided by d, the remainder obtained is zero. For example, for number 12, there are 6 factors 1, 2, 3, 4, 6, 12. Every positive integer k has at least two factors, 1 and the number k itself. Given two positive integers N and k, write a program to print the kth largest factor of N.
Input Format: The input is a comma-separated list of positive integer pairs (N, k)
Output Format: The kth highest factor of N. If N does not have k factors, the output should be 1.
Constraints: 1<N<10000000000. 1<k<600. You can assume that N will have no prime factors which are larger than 13.
Q5. Collecting Candies
Krishna loves candies a lot, so whenever he gets them, he stores them so that he can eat them later whenever he wants to.
He has recently received N boxes of candies each containing Ci candies where Ci represents the total number of candies in the ith box. Krishna wants to store them in a single box. The only constraint is that he can choose any two boxes and store their joint contents in an empty box only. Assume that there is an infinite number of empty boxes available.
At a time he can pick up any two boxes for transferring and if both the boxes say contain X and Y number of candies respectively, then it takes him exactly X+Y seconds of time. As he is to eager to collect all of them he has approached you to tell him the minimum time in which all the candies can be collected.
Input Format:
The first line of input is the number of test case T
Each test case is comprised of two inputs
The first input of a test case is the number of boxes N
The second input is N integers delimited by whitespace denoting the number of candies in each box
Output Format:
Print minimum time required, in seconds, for each of the test cases. Print each output on a new line.
Constraints:
1 ?T?10
1 ?N? 10000
1 ? [Candies in each box] ? 100009
No comments:
Post a Comment