TCS CODE VITA 2022 QUESTIONS asked in 2022 in March are GIVEN and TCS Code Vita Complete Guide is Explained in Brief in this article. TCS OCde vita for UG and PG in IT/Computers for freshers Codevita 2022 Question
About TCS CodeVita
CodeVita is an online Coding Competition conducted by the top MNC TCS i.e. TCS code vita
where the Tech Folks across the Globe do Participate Here to Solve the Competetive Programming Question.
TCS CodeVita happens from 2012 and currently is Season 10
TCS CodeVita Questions Pre-Qualifier round is a 6-hour Online coding challenge. You could attempt the test at your convenience within the given 24 hours of time. This round is a non-proctored round (No webcam access required).
Benefits of TCS CodeVita
- Global ranking to top coders
- Top 3 coders to win total a prize money of USD 20,000/-
- A chance to explore exciting careers* with one of the world's most powerful brand
- A chance to compete with some of the best coders in the world
- A platform to showcase your programming skills
- The finalists stand a chance to travel** to India for the season 10 live grand finale experience.
Which Programming Languages to used in TCS CodeVita?
In TCS CodeVita the Programming Languages can be written in the following given languages C, C++, C#, Java, Perl, PHP, Python, Ruby.
How Many Rounds Are there in TCS CodeVita?
There are 3 rounds in TCS CodeVita Competition,
- Pre Qualifier -- Online
- Qualifier -- Online
- Grand Finale -- Online/India
How to Participate in TCS CodeVita?
- Go to TCS CodeVita Official Website from TCS.
- Do Register to the CodeVita Website
- After the Registration Time Ends, You will receive a Mail Regarding the TCS CodeVita
- Later, You will get the Mock Rounds to Check and Easy Access to the CodeVita Website
- Finally, You will get the Date to Begin the Competition.
What Graduation is required to be Eligible For TCS CodeVita?
Any UG in CS/IT Domain. such as BCA, BSc, BE, B.Tech, MCA, MSc, ME, M.Tech.
Which Batch is Eligible for TCS CodeVita?
-2nd Year > -1 Year > CURRENT YEAR > +1 Year > +2 Year > +3 Year.
Eg.
Current Year:2022
2020, 2021, 2022, 2023, 2024 and 2025.
Are TCS Employees Eligible for TCS CodeVita?
No. It's Not for Folks Who are Already Being TCS Employee
TCS Codevita Questions Asked in 2022
1. College Rank I
College Admissions are done by allocating a seat to a student based on his/her preference and percentage scored. Students are asked to provide three colleges of their choice. Each college will have a quota of S seats (S can vary per college). Admissions will be processed based on 'percentage scored' and availability of seats as per 'choice of preference'.
Admissions will first be granted based on the percentage scored. If there is a tie, on the percentage scored, then admission will be granted based on student Id i.e. student with a lower Id will be given preference over a student with a higher Id.
All admissions will be processed based on students' choice i.e. if a student is eligible to get admitted to any of the 3 colleges, s/he will have to be admitted. Similarly, it will be binding on the student to get admitted. Obviously, the first choice will get first preference, second choice will get second preference and so on.
Find the list of students who got admitted in any college of their choice.
3<=C<=25
1<=N<=10000
1<=Si<=120
First line contains two integers viz. C and N where,
C is number of colleges and
N is number of students
Second line contains C spaced integers denoting S1, S2 and so on till SC - where S1 is number of seats in college 1, S2 in college 2 etc.
Next, N lines comprise of 5 data items, viz <student-id, percentage, Choice 1, Choice 2, Choice 3>
Display the students who got admitted in any college of their choice in descending order of their percentages. If there is a tie, on percentage scored, then print lower student Id ahead of higher student Id.
The output format is <student-id college>
For better understanding go through the Examples given below.
Time Limit (secs)
1
Input
3 5
3 1 2
Student-1,97.05,C-1,C-3,C-2
Student-2,48.03,C-1,C-2,C-3
Student-3,85.69,C-1,C-3,C-2
Student-4,80.83,C-1,C-3,C-2
Student-5,41.23,C-1,C-2,C-3
Output
Student-1 C-1
Student-3 C-1
Student-4 C-1
Student-2 C-2
Student-5 C-3
Explanation
Here student-1 with highest percentage gets his first preferred college, then the next top scorer, Student-3 gets his first preferred college and so on.
However, we can see that there are only three seats in college 1 so only students with good percentage get admitted (i.e., student-1, student-3, student-4).
Now college 1 allocation quota is complete. Hence no new student can be admitted to college 1. college 2 and college 3 still have one and two seats respectively. Now, Student-2 and Student-5 are yet to be admitted.
Both student's priority is college 2 as second choice, but Student-2 is admitted to college 2 due to higher percentage (i.e., Student-2 Percentage> Student-5 Percentage).
Now there are only 0,0,2 seats left in college 1, college 2 and college 3 respectively. So, Student-3 is admitted to college 3.
Example 2
Input
4 5
2 1 1 1
Student-1,97.05,C-1,C-3,C-2
Student-2,48.03,C-1,C-2,C-3
Student-3,85.69,C-1,C-3,C-2
Student-4,80.83,C-1,C-3,C-2
Student-5,41.23,C-1,C-2,C-3
Output
Student-1 C-1
Student-3 C-1
Student-4 C-3
Student-2 C-2
Explanation
Here allocation is done based on percentage and preference, that is student with high percentage is admitted based on his choice of preference. So, Student-1, Student-2, Student-3, Student-4 is admitted based on their score and choice. However, Student-5 is left unadmitted because all the choice of his/her colleges is full. So, Student-5 is not displayed in output.
2. Polygon
You are given N number of coordinates and you have to create a polygon from these points such that they will make a polygon with maximum area.
Note: coordinates provided in the input may or may not be in sequential form.
1 <= N <= 10
First line contains an integer0 N which depicts number of co-ordinates
Next N lines consist of two space separated integers depicting coordinates in the form of x y
Print the maximum possible area by creating a polygon by joining the coordinates. If the area is in decimal form, print the absolute value as output.
Time Limit (secs)
1
Examples
Input
4
0 0
2 0
0 2
2 2
Output
4
Explanation:
As we can imagine that these points will make a square shape and the maximum possible area made by the polygon will be 4.
Example 2
Input
5
3 1
0 0
3 0
3 3
0 3
Output
9
Explanation:
All the coordinates will create a polygon with a maximum area of 9.
3. Rank And Subset
Problem Description
You are given N comma-separated Strings. You need to form all possible legal subsets of these N strings. These subsets will be a combination of zero or more of these N Strings. After forming the subsets, they will be ranked in a particular order. The legal subset formation and ranking logic is as described below
• Rank 1 will always be an empty set
• Next N ranks will be the N Strings that appear in the order they are provided in the input
• After N + 1 ranks, you need to combine N strings such that all legal combinations are formed
• Legal combination simply means that while combinations are formed, the string that appears to the left of a particular string in the input, can never appear to the right of that particular string, when subsets are formed
• A subset with less elements will be ranked higher than a subset with more elements (NOTE:- Rank 1 is higher than rank 2)
• Refer to Example 2 to get a better understanding of how subsets are formed and ranked
It is guaranteed that
• N >=1
• All N strings are unique
Example, say you have an input string "aa,cc,bb". In this string there are 3 comma-separated strings. From these strings we need to create all possible legal subset of strings. 8 legal subsets can be formed from these strings. And they are as follows:
1: {}
2: {aa}
3: {cc}
4: {bb}
5: {aa,cc}
6: {aa,bb}
7: {cc,bb}
8: {aa,cc,bb}
NOTE: - Here we can see the ranks given to the subsets are first by size i.e., the subset with lesser number of strings is ranked higher than the subset with higher size. If the subsets have equal number of strings then, the combination which is formed earlier (by virtue of combining strings in order they appear in input), gets a higher rank.
For instance, rank of subset {aa,cc} > rank of {aa,bb} because string cc is appearing prior to string bb in the input . Similarly, rank of {cc} > rank of {bb}.
You are provided one legal subset from all possible legal subsets. Your task is to find it's rank according to the constraints given.
Constraints
0 < N <= 10^2
0 < Rank <= 10^18
Input
First line contains an integer N which is number of strings in group.
Second line contains comma separated strings for which you need to find the rank.
Third line contains N comma-separated strings basis which the subsets should be formed
Output
From all possible legal subsets find the rank of subset as asked in line 2 of the input
Time Limit (secs)
1
Examples
Input
2
a,b
a,b
Output
4
Explanation:
Given that N = 2, given
Second line: Rank to be find: a,b
Third line: Given group of strings: a,b
Possible subsets & Rank
{} - 1
{a} -2
{b} - 3
{a, b} - 4
Output - 4 (4th rank corresponds to a,b)
Example 2
Input
3
abc,dab
abc,dab,bc
Output
5
Explanation:
Given that N = 3, given
Second line: Rank to be find: abc,dab
Third line: Given group of strings: abc,dab,bc
Possible subsets & Rank
{} - 1
{abc} - 2
{dab} - 3
{bc} - 4
{abc,dab} - 5
{abc,bc} - 6
{dab,bc} - 7
{abc,dab,bc} - 8
Output - 5 (5th rank corresponds to abc,dab)
Note: Here we can see the rank of {dab} < {bc} and rank of {abc,dab} < rank of {abc,bc}. Because in the input string, string dab is appearing before string bc.
4. Docstore Offline
Problem Description
Docstore is a utility which is used to store documents in a file/container. And while writing or storing the file you must know the exact location of the document where you are writing it. You must know what is the starting offset and ending offset of that particular file. And these all entries are inserted into the database so that at the time of reading of file you directly start reading from that offset and return the file.
You have been provided a list of files and its subsequent details. Soft deletion flag will be given. You can use that space to accommodate the new file. If deletion flag is 0 file is not soft deleted. You have been given a list of files with their size. You have insert file at a place where it gets the best fit.
Best fit- Order will be
• Exact match with the free space.
• Insert where there is Least Internal fragmentation.
• If none of them is possible append after last file.
Print the starting offset of every file inserted in sorted order of file name.
Note- b=byte, kb=kilobytes, mb=megabyte
Constraints
1<N<100
1<M<100
Input
First line contains an integer denoting the number of files (N) already present in the disk.
Next lines contain space separated data about every file in the format given below
Filename Offset Size DeletionStatus
Next line contains an integer denoting the number of files(M) to be inserted.
Next M lines contains space separated data about every file in the format given below
Filename Size
Output
Print the starting offset of every file inserted in sorted(lexicographically) order of file name.
Time Limit (secs)
1
Examples
Input
4
File1 0 2b 0
File2 2 3b 1
File3 5 1b 0
File4 6 4b 0
2
File5 2b
File6 3b
Output
File5 2
File6 10
Explanation-
Here we have to add file5 so will check of free spaces with exact match. But there is no exact match. Now we will check for least internal fragmentation. So file2 is deleted and we have 3b space. So, we can accommodate file5 at the position of file2 with 1b internal fragmentation.
Now we have to insert file6 so will check of free spaces with exact match. But there is no exact match. Now we will check for least internal fragmentation. But here we don't have any space which can accommodate the file. Finally, we will add that file after the last file written. Hence it will be stored at offset 10 after file4 completion.
Example 2
Input
3
File1 0 2b 0
File2 2 3b 0
File3 5 1b 0
2
File4 1b
File5 7b
Output
File4 6
File5 7
Explanation-
Here we have to add file4 and file5 so will check of free spaces and all the cases but no space is present to occupy any file so they will be added at the last. One after another.
5.Sit Together
Problem Description
You are a caretaker of a waiting room and you have to take care of empty seats such that all the people should sit together. Imagine the seats are in a straight line like in a movie theatre. People are seated on random seats initially. Your task is to make them sit together so that minimum number of people change their position. Also, they can be made to sit together in many ways. Find the number of ways you can make them sit together by requiring only minimal people movement.
"E" depicts an empty seat and "O" depicts an occupied seat. Input will be given in the form of a string.
Example: OEOEO
As we can see, only seat number 1, 3, 5 are occupied and 2 and 4 are empty.
Case 1: If we move 5th person to 2nd position, they can all be together with only one person moving his/her place.
Case 2: If we move 1st person to 4th position, they can all be together with only one person moving his/her place.
They can all be together with only one movement and this can be done in 2 ways. Print the minimum number of movements required and the number of ways this minimum movement can help achieve the objective.
Note: If they are already sitting together, Print "0 0" as output.
Constraints
0 < N <= 100000
Input
First line contains an integer N which depicts the number of seats
Second line contains N characters each of which are either "O" or "E". "O" denotes an occupied seat and "E" denotes an empty seat.
Output
Print minimum number of movements required and the number of ways in which all people can be made to sit together without exceeding minimum number of movements by space.
Time Limit (secs)
1
Examples
Input
5
OEOEO
Output
1 2
Explanation:
Given data of 5 seats in the queue,
Seat number 2 and 4 are unoccupied and all the other seats are occupied.
We can make them sit together by moving only one person near to the other. It can be done in 2 ways:
OOOEE {Moving 4th person to 2nd position}
EEOOO {Moving 1st person to 4th position}
Example 2
Input
2
OO
Output
0 0
Explanation:
All seats are occupied and all of them are sitting together. So, output will be 0 0.
6. IPL
Problem Description
The Indian Premier League (IPL) is a professional Twenty20 cricket league, contested by eight teams based out of eight Indian cities. IPL is going to start and, in this season, you have been given the responsibility to maintain the score board of the league. You have been provided the result of each match. Total 8 teams compete (MI, CSK, RCB, RR, SRH, DC, PKBS, KKR) for winning the title. Each team will play two matches with every other team before playoffs. So, the total number of matches before playoffs will be 56 league matches.
The format in which the scores will be given is - the runs scored by team batting first followed by the fall of wickets followed by the number of balls played. The same data will be provided for team batting second.
For example-
Abstract Format - FirstTeamName Runs/Wickets BallsPlayed SecondTeamName Runs/Wickets BallsPlayed
Actual Record - MI 191/10 110 CSK 190/4 120
Here MI scored 191 runs in110 balls at the loss of 10 wickets and CSK scored 190 runs at the loss of 4 wickets in 120 balls.
The points table is to be constructed based on the given inputs. The points table contains <TeamName, TotalPointsScored by team, and NRR (Net Run Rate)>. The order in which teams will be present is based on the ranking. Ranking of teams is first based on number of points and then on NRR, in case the points are tied.
The points table formation rules are given below-
• The team winning the match will get 2 points.
• NET RUN RATE is calculated as follows:
Case 1: When both teams make same score. Each team is rewarded with 1 point each and run rate is zero for both the teams.
Case 2: Team batting first wins the match
In this scenario, the margin of runs by which team wins are multiplied by 0.05 and we get run rate of the match.
Run rate= (Runs Difference) *0.05
Case 3: Team Batting second wins the match.
In this scenario total runs which would have been scored by the winning team if it had batted 20 overs (120 balls) are calculated and the difference with the first team is taken.
run rate= (Projected score of winning team - score of losing team) *0.05
For example - team1 = 159 and team2 scores 160 in 96 balls (16.0 overs). Here, team2 scored 160 runs in 96 balls so runs that can be scored in 120 balls is 200. So, the projected score for team2 is 200.
The winning teams gets positive RR and the losing team gets negative RR.
Net Run rate= sum of run rate of individual matches/total number of matches.
Note - There are no test cases where the teams have same points and same NRR by the end of league matches.
For reference about Cricket and IPL
Cricket T20 - https://en.wikipedia.org/wiki/Twenty20
IPL- https://en.wikipedia.org/wiki/Indian_Premier_League
Constraints
N=56 where N is the number of league matches
Input
It contains 56 lines which represent the result for every match in the format provided in problem description
Output
Print the ranking of all the team in points table. Sort order should be points scored, followed by NRR.
Time Limit (secs)
1
Examples
Input
MI 206/9 120 DC 164/4 120
RR 197/9 120 SRH 176/10 120
CSK 130/3 120 DC 111/9 120
KKR 217/1 120 DC 190/9 120
SRH 163/8 120 PBKS 167/7 104
MI 167/5 120 RR 171/5 86
CSK 201/6 120 SRH 135/9 120
KKR 207/8 120 DC 178/4 120
CSK 121/9 120 RCB 125/8 79
KKR 176/3 120 PBKS 153/9 120
MI 193/1 120 KKR 142/3 120
CSK 118/3 120 KKR 122/1 66
RR 156/4 120 DC 135/6 120
SRH 143/6 120 PBKS 128/1 120
MI 143/7 120 RCB 147/2 109
SRH 201/8 120 DC 205/4 88
DC 115/2 120 RCB 119/4 71
MI 215/10 99 DC 111/9 120
RR 137/9 120 DC 112/7 120
MI 164/2 120 RCB 168/4 90
KKR 203/7 120 SRH 113/4 120
MI 134/7 120 PBKS 123/4 120
KKR 112/4 120 RR 116/4 94
MI 128/6 120 KKR 132/6 110
CSK 122/6 120 KKR 126/3 69
RR 210/4 120 PBKS 113/1 120
CSK 187/1 120 RR 151/3 120
SRH 216/7 120 RCB 131/5 120
KKR 121/3 120 RCB 125/3 103
MI 131/8 120 SRH 135/6 79
CSK 199/8 120 SRH 148/10 120
MI 169/9 120 CSK 140/9 120
CSK 191/6 120 RR 110/2 120
MI 140/10 71 SRH 144/5 87
RR 159/10 106 RCB 157/10 120
PBKS 131/3 120 DC 135/3 89
CSK 206/7 120 RCB 156/5 120
PBKS 112/5 120 RCB 116/7 62
RR 211/10 67 RCB 143/5 120
KKR 190/3 120 SRH 176/10 120
PBKS 113/9 120 RCB 117/7 84
RR 164/5 120 PBKS 127/9 120
CSK 147/10 117 DC 151/1 72
SRH 171/8 120 DC 142/10 120
KKR 209/8 120 PBKS 182/7 120
CSK 205/6 120 PBKS 190/3 120
MI 154/3 120 PBKS 147/5 120
KKR 218/9 120 RCB 140/6 120
MI 118/9 120 RR 122/7 83
SRH 178/2 120 RCB 131/8 120
DC 146/3 120 RCB 140/4 120
CSK 151/2 120 PBKS 126/7 120
MI 128/9 120 CSK 132/1 81
PBKS 171/2 120 DC 162/3 120
KKR 130/5 120 RR 134/10 102
RR 133/8 120 SRH 137/2 99
Output
RR
KKR
CSK
RCB
SRH
MI
DC
PBKS
Explanation-
In this case RR, KKR, CSK, RCB, SRH, MI, DC, PBKS has won 11, 10, 9, 7, 7, 6, 4, 2 matches respectively. SRH and RCB has same number of points but the NRR of RCB is higher than SRH so its rank is above SRH.