New
Know More
New
Know More
New
Know More
View All Preparation Packages

TCS CodeVita

No of Coding Questions
Coding Questions :
85
No. of MCQ Questions
MCQ Questions :
0
No. of Mock Tests
Mock Test :
Coming Soon
Arrow leading towards next section of Landing Page

About TCS Codevita Exam

The TCS Codevita competition, organized by Tata Consulting Services, is a renowned global programming contest. The competition is held annually and is conducted online, lasting for a full 24 hours. It provides an excellent opportunity for aspiring programmers to showcase their skills and compete against the best coders from around the world.

The primary goal of this contest is to identify and recognize top-performing coders, and offer them the chance to pursue career opportunities with Tata Consultancy Services. 

There are some exciting prizes to be won:

  1.   1st Prize: US$ 10,000 | 2nd Prize: US$ 7,000 | 3rd Prize: US$ 3,000.
  2.   Internship opportunity with CTO Research Team.
  3.   Waiver in the Aptitude Test of the TCS Placements process for good performers.
  4.   Up to 3000 Job offers for top coders.
  5.   Global Ranking to Top Coders.

Benefits of TCS Codevita Exam

  1. Students in their 2nd and 3rd year have the opportunity to intern with Tata Consulting Services (TCS) if they are selected
  2. Final year students who clear the first round are eligible for an interview and a minimum package of CTC 3.5 LPA
  3. Clearing the second round of the competition leads to an interview for a package of 8 LPA + and the possibility of being allocated to a cutting-edge technology project
  4. Job roles available through TCS Codevita include Assistant Systems Engineer and Systems Engineer
  5. 3000+ job offers for top performers in the competition
  6. The top 3 coders will receive a total prize money of 20,000 USD
  7. Opportunity to compete with some of the best coders in the world and showcase programming skills.

Eligibility criteria for TCS Codevita Exam

  • The eligibility criteria for TCS Codevita season 10 is as follows:
  • This contest is open for graduates of 2021,2022,2023,2024, and 2025.
  • This contest is not open to employees of TCS.
  • UnderGraduates/PostGraduates related to Engineering & Science background in any domain are eligible.

Syllabus for TCS Codevita

Quantitative Aptitude:

  • Ages: 0-1 question
  • Profit and Loss: 0-1 question
  • Time and Work: 0-1 question
  • Averages: 0-1 question
  • Simple and Compound Interest: 0-1 question
  • Prime Products: 0-1 question
  • LCM and HCF: 0-1 question
  • Equations: 0-1 question
  • Divisibility: 0-1 question
  • Boats and Streams: 0-1 question
  • Permutation and Combination: 0-1 question
  • Data Interpretation: 0-1 question
  • Allegation and Mixture: 0-1 question
  • Probability: 0-1 question

Logical Reasoning:

  • Number Series: 0-3 questions
  • Blood Relations: 0-2 questions
  • Time and Work: 0-4 questions
  • Analogies: 0-1 questions
  • Statement and Conclusions: 0-2 questions
  • Odd Man Out: 0-2 questions
  • Data Sufficiency: 0-4 questions
  • Seating Arrangement: 0-2 questions
  • Cubes and Dices: 0-3 questions
  • Shape and Construction: 0-3 questions
  • Pattern Completion: 0-3 questions
  • Coding-Decoding: 0-3 questions
  • Mathematical Ordering: 0-2 questions

Tech Test:

  • Coding: 1 question
  • SEO: 0-3 questions
  • SDK: 0-3 questions
  • Stackoverflow: 0-1 questions
  • Looping: 0-2 questions
  • HTTPS: 0-3 questions
  • Javascript & CSS: 0-1 questions
  • Interpreter: 0-2 questions
  • Hardware abstracts: 0-2 questions
  • Flowcharts in CS: 0-1 questions
  • Email protocol Pop3 | SMTP | HTTP | FTP: 0-1 questions
  • Runtime Errors: 0-2 questions
  • GIT: 0-3 questions
  • Code - Reuse Functions: 0-1 questions
  • Primary Key: 0-2 questions
  • DBMS Language: 0-1 questions
  • Ping: 0-1 questions
  • OOPs Abstraction | Inheritence | Encapsulation | Polymorphism: 0-2 questions
  • Storage classes: 0-2 questions

English - Verbal:

  • Fill in the Blanks: 0-3 questions
  • Error Detection: 0-3 questions
  • One Word Substitution: 0-1 questions
  • Tenses and Articles: 0-2 questions
  • Proposition and Conjunction: 0-3 questions
  • Error Identification: 0-1 questions
  • Antonyms: 0-2 questions
  • Synonyms: 0-2 questions
  • Analogies: 0-1 questions
  • Sentence Completion: 0-1 questions
  • Sentence Correction: 0-2 questions
  • Spellings: 0-3 questions
  • Reading Comprehension: 1 question (5 sub-questions)

TCS Codevita Exam Pattern

Okay, now move further to the exam pattern and other contest details. CodeVita is an online coding contest that consists of 3 major rounds: Pre-Qualifier Round, Qualifier Round, and Grand Finale.

1. Pre-Qualifier Round: It will be an online coding contest in which the participants need to solve the questions within 6 hours. Meanwhile, there will two zonal rounds for the Pre-Qualifier Stage in India. Moreover, the participants will be tagged to a particular contest zone based on the form details.

  • Mode: Online
  • Starts from: July 10, 2020, 09:30 UTC
  • Ends On: July 25, 2020, 09:30 UTC

2. Qualifier Round: Once you’ll get done with Pre-Qualifier rounds, then the Qualifier Round will take place on a particular day for both Indian and other students. The top performers in the zonal rounds will be promoted to this qualifier round. In this round, each participant is provided with 6 hours to solve the questions.

  • Mode: Online
  • Starts from: November 07, 2020, 09:30 UTC
  • Ends On: November 08, 2020, 09:30 UTC

3. Grand Finale: It will be the final round where the top performers from the second round (Qualifier round) will participate. It will be held in one of the TCSL offices in India. The Top 3 contestants in this round will be declared as winners of the contest. Also, the winners will receive a total cash prize of USD 20, 000.

  • Mode: Takes Place At the Venue
  • Starts from: February 17, 2021, 03:30 UTC

Ends On:February 17, 2021, 12:30 UTC

Arrow leading towards next section of Landing Page

TCS Selection Process

The TCS Codevita selection process is a multi-round competition that is designed to identify and recognize the top-performing coders. The competition is open to students in their 2nd year and above, and it is held annually.

The competition begins with a 24-hour online coding challenge, where contestants are required to solve a set of programming problems within the given time frame. The problems are designed to test the contestants' coding skills, logical thinking, and problem-solving abilities.

Based on their performance in the first round, a select group of contestants will be chosen to proceed to the next round. This round is typically an online test that further evaluates the contestants' coding skills and knowledge of programming languages.

After clearing the online test, the selected contestants will then proceed to the interview round. 

Technical Round: It the first round of the interview process, where the candidates' technical skills and knowledge of programming languages are evaluated. The interviewer will ask questions related to the candidate's programming experience, projects, and problem-solving abilities.

Managerial Round: which is the second round of the interview process, is focused on evaluating the candidate's leadership skills, team management abilities and their understanding of the industry and business. Candidates are expected to demonstrate their ability to handle projects, work with cross-functional teams, and provide solutions to business problems.

HR Round: The final round of the interview process, where the interviewer will assess the candidate's communication skills, attitude, and overall fit with the company culture. The interviewer will also provide an overview of the company's benefits and other relevant information about the role.

Based on the overall performance in the competition, the top performers will be offered job roles such as Assistant Systems Engineer and Systems Engineer at TCS. Additionally, the top 3 coders will win a total prize money of 20,000 USD, and there will be 3000+ job offers for the top performers in TCS Codevita.

Overall, the TCS Codevita selection process is an excellent opportunity for aspiring programmers to showcase their skills and compete against the best coders from around the world, while also earning recognition and pursuing career opportunities with TCS.

Note: The selection process may vary depending on the role and location. The company reserves the right to add or remove stages as per the requirement.

Arrow leading towards next section of Landing Page

Popular Questions

#Question 1

A solid cube of 10 cm x 10cm x 10 cm rests on the ground.  It has a beetle on it, and some sweet honey spots at various locations on the surface of the cube.  The beetle starts at a point on the surface of the cube, and goes to the honey spots in order along the surface of the cube.

#Problem Description

A solid cube of 10 cm x 10cm x 10 cm rests on the ground.  It has a beetle on it, and some sweet honey spots at various locations on the surface of the cube.  The beetle starts at a point on the surface of the cube, and goes to the honey spots in order along the surface of the cube.

1. If it goes from a point to another point on the same face (say X to Y), it goes in an arc of a circle that subtends an angle of 60 degrees at the centre of the circle

2.If it goes from one point to another on a different face, it goes by the shortest path on the surface of the cube, except that it never travels along the bottom of the cube

The beetle is a student of Cartesian geometry, and knows the coordinates (x, y, z) of all the points it needs to go to.  The origin of coordinates it uses is one corner of the cube on the ground, and the z axis points up.  Hence, the bottom surface (on which it does not crawl) is z=0, and the top surface is z=10.  The beetle keeps track of all the distances travelled, and rounds the distance travelled to two decimal places once it reaches the next spot, so that the final distance is a sum of the rounded distances from spot to spot.

#Input

```sh

The first line gives an integer N, the total number of points (including the starting point) the beetle visits

The second line is a set of 3N comma separated non-negative numbers, with up to two decimal places each.  These are to be interpreted in groups of three as the x, y, z coordinates of the points the beetle needs to visit in the given order.

```

#Output

```sh

One line with a number giving the total distance travelled by the beetle accurate to two decimal places.  Even if the distance travelled is an integer, the output should have two decimal places.

```

#Constraints

```sh

None of the points the beetle visits is on the bottom face (z=0) or on any of the edges of the cube (the lines where two faces meet)

2<=N<=10

```

#Question 1

Write a program to find the factorial of a given number

#Solution 1

```sh

def factorial(n):

if n == 0:

return 1

else:

return n * factorial(n-1)

print(factorial(5))

```

#Question 2

Write a program to find the Fibonacci series of a given number.

#Solution 2

```sh

def fibonacci(n):

if n <= 0:

return 0

elif n == 1:

return 1

else:

return fibonacci(n-1) + fibonacci(n-2)

print(fibonacci(6))

```

#Question 2

The parcel section of the Head Post Office is in a mess.  The parcels that need to be loaded to the vans have been lined up in a row in an arbitrary order of weights.  The Head Post Master wants them to be sorted in the increasing order of the weights of the parcels, with one exception.  He wants the heaviest (and presumably the most valuable) parcel kept nearest his office.

#Problem Description

The parcel section of the Head Post Office is in a mess.  The parcels that need to be loaded to the vans have been lined up in a row in an arbitrary order of weights.  The Head Post Master wants them to be sorted in the increasing order of the weights of the parcels, with one exception.  He wants the heaviest (and presumably the most valuable) parcel kept nearest his office.

 You and your friend try to sort these boxes and you decide to sort them by interchanging two boxes at a time.  Such an interchange needs effort equals to the product of the weights of the two boxes. 

The objective is to reposition the boxes as required with minimum effort.

#Input

```sh

The first line consists of two space separated positive integers giving the number of boxes (N) and the position of the Head Post Masters office (k) where the heaviest box must be.

The second line consists of N space separated positive integers giving the weights of the boxes.  You may assume that no two weights are equal.

```

#Output

```sh

The output is one line giving the total effort taken to get the boxes in sorted order, and the heaviest in position k.

```

#Constraints

```sh

N<=50

Weights <= 1000

```

#Question 3

In the theory of numbers, square free numbers have a special place.  A square free number is one that is not divisible by a perfect square (other than 1).

#Problem Description

In the theory of numbers, square free numbers have a special place.  A square free number is one that is not divisible by a perfect square (other than 1).  Thus 72 is divisible by 36 (a perfect square), and is not a square free number, but 70 has factors 1, 2, 5, 7, 10, 14, 35 and 70.  As none of these are perfect squares (other than 1), 70 is a square free number.

For some algorithms, it is important to find out the square free numbers that divide a number.  Note that 1 is not considered a square free number. 

In this problem, you are asked to write a program to find the number of square free numbers that divide a given number.

#Input

```sh

The only line of the input is a single integer N which is divisible by no prime number larger than 19

```

#Output

```sh

One line containing an integer that gives the number of square free numbers (not including 1)

```

#Constraints

```sh

N   < 10^9

```

#Question 3 

Write a program to check if a given number is prime or not.

#Answer 3

```sh

def is_prime(n):

if n <= 1:

return False

for i in range(2, n):

if n % i == 0:

return False

return True

print(is_prime(7))

```

#Question 4

Write a program to reverse a given string

#Answer 4

```sh

def reverse_string(string):

return string[::-1]

print(reverse_string("Hello World"))

```

#Question 5

Write a program to find the largest and second largest element in an array.

#Solution 5

```sh

def find_largest_elements(arr):

largest = max(arr[0], arr[1])

second_largest = min(arr[0], arr[1])

for i in range(2, len(arr)):

if arr[i] > largest:

second_largest = largest

largest = arr[i]

elif arr[i] > second_largest:

second_largest = arr[i]

return largest, second_largest

print(find_largest_elements([3, 5, 2, 7, 4, 8, 1]))

```

Testimonials

Dileep

Placed in
TCS Digital
-
7 LPA+

Being a mechanical student and getting into an IT company is very tough. One of the main reason I could able to crack TCS CodeVita is because of Edyst.
Aneeq sir, your doubt clearing sessions, daily assignments & incredible mentors support really brushed up my skills.

Madhavi

Placed in
TCS
-

“My software journey started because of Edyst. Edyst preparation and referrals helped me get my first internship and job. Thank you Edyst!

Manikanta Javvadi

Placed in
Phenom People
-
15 LPA

Daily coding challenge and the doubt session helped me in staying consistent. Also, the leadership board kept me motivated. Edyst gave me the best guiding materials for all the cohorts I joined. I like everything done by Edyst for my success.

Rahil Sayed

Placed in
FIS Global
-
8.6 LPA

I really like the Company specific practice questions they turn out to be super helpfulduring my interview, I didn't face any difficulty, the variety and range of practice questions (especially on arrays) got me my dream job. Also, the online live session were very interactive and helped me in revision and solving doubts. Thank you Edyst.

Saritha

Placed in
Hooper
-

I practice a lot at Edyst platform and what I learnt is how to code, self-learning and more & more about the practical knowledge which gradually increased my confidence level. Edyst was great platform which changed my career.

Harika

Placed in
DBS
-
7 LPA

I feel the best thing about edyst is its company-specific guidance and the huge problem sets covering up almost all the concepts from beginner to advanced concepts, it helped me a lot for my placement preparation

Arrow leading towards next section of Landing Page

Coding Interview Round Sample Questions 

Here are some examples of coding interview questions that may be asked (entry-level candidates with little or no professional experience):

#Question 1

A solid cube of 10 cm x 10cm x 10 cm rests on the ground.  It has a beetle on it, and some sweet honey spots at various locations on the surface of the cube.  The beetle starts at a point on the surface of the cube, and goes to the honey spots in order along the surface of the cube.

#Problem Description

A solid cube of 10 cm x 10cm x 10 cm rests on the ground.  It has a beetle on it, and some sweet honey spots at various locations on the surface of the cube.  The beetle starts at a point on the surface of the cube, and goes to the honey spots in order along the surface of the cube.

1. If it goes from a point to another point on the same face (say X to Y), it goes in an arc of a circle that subtends an angle of 60 degrees at the centre of the circle

2.If it goes from one point to another on a different face, it goes by the shortest path on the surface of the cube, except that it never travels along the bottom of the cube

The beetle is a student of Cartesian geometry, and knows the coordinates (x, y, z) of all the points it needs to go to.  The origin of coordinates it uses is one corner of the cube on the ground, and the z axis points up.  Hence, the bottom surface (on which it does not crawl) is z=0, and the top surface is z=10.  The beetle keeps track of all the distances travelled, and rounds the distance travelled to two decimal places once it reaches the next spot, so that the final distance is a sum of the rounded distances from spot to spot.

#Input

```sh

The first line gives an integer N, the total number of points (including the starting point) the beetle visits

The second line is a set of 3N comma separated non-negative numbers, with up to two decimal places each.  These are to be interpreted in groups of three as the x, y, z coordinates of the points the beetle needs to visit in the given order.

```

#Output

```sh

One line with a number giving the total distance travelled by the beetle accurate to two decimal places.  Even if the distance travelled is an integer, the output should have two decimal places.

```

#Constraints

```sh

None of the points the beetle visits is on the bottom face (z=0) or on any of the edges of the cube (the lines where two faces meet)

2<=N<=10

```

#Question 1

Write a program to find the factorial of a given number

#Solution 1

```sh

def factorial(n):

if n == 0:

return 1

else:

return n * factorial(n-1)

print(factorial(5))

```

#Question 2

Write a program to find the Fibonacci series of a given number.

#Solution 2

```sh

def fibonacci(n):

if n <= 0:

return 0

elif n == 1:

return 1

else:

return fibonacci(n-1) + fibonacci(n-2)

print(fibonacci(6))

```

#Question 2

The parcel section of the Head Post Office is in a mess.  The parcels that need to be loaded to the vans have been lined up in a row in an arbitrary order of weights.  The Head Post Master wants them to be sorted in the increasing order of the weights of the parcels, with one exception.  He wants the heaviest (and presumably the most valuable) parcel kept nearest his office.

#Problem Description

The parcel section of the Head Post Office is in a mess.  The parcels that need to be loaded to the vans have been lined up in a row in an arbitrary order of weights.  The Head Post Master wants them to be sorted in the increasing order of the weights of the parcels, with one exception.  He wants the heaviest (and presumably the most valuable) parcel kept nearest his office.

 You and your friend try to sort these boxes and you decide to sort them by interchanging two boxes at a time.  Such an interchange needs effort equals to the product of the weights of the two boxes. 

The objective is to reposition the boxes as required with minimum effort.

#Input

```sh

The first line consists of two space separated positive integers giving the number of boxes (N) and the position of the Head Post Masters office (k) where the heaviest box must be.

The second line consists of N space separated positive integers giving the weights of the boxes.  You may assume that no two weights are equal.

```

#Output

```sh

The output is one line giving the total effort taken to get the boxes in sorted order, and the heaviest in position k.

```

#Constraints

```sh

N<=50

Weights <= 1000

```

#Question 3

In the theory of numbers, square free numbers have a special place.  A square free number is one that is not divisible by a perfect square (other than 1).

#Problem Description

In the theory of numbers, square free numbers have a special place.  A square free number is one that is not divisible by a perfect square (other than 1).  Thus 72 is divisible by 36 (a perfect square), and is not a square free number, but 70 has factors 1, 2, 5, 7, 10, 14, 35 and 70.  As none of these are perfect squares (other than 1), 70 is a square free number.

For some algorithms, it is important to find out the square free numbers that divide a number.  Note that 1 is not considered a square free number. 

In this problem, you are asked to write a program to find the number of square free numbers that divide a given number.

#Input

```sh

The only line of the input is a single integer N which is divisible by no prime number larger than 19

```

#Output

```sh

One line containing an integer that gives the number of square free numbers (not including 1)

```

#Constraints

```sh

N   < 10^9

```

#Question 3 

Write a program to check if a given number is prime or not.

#Answer 3

```sh

def is_prime(n):

if n <= 1:

return False

for i in range(2, n):

if n % i == 0:

return False

return True

print(is_prime(7))

```

#Question 4

Write a program to reverse a given string

#Answer 4

```sh

def reverse_string(string):

return string[::-1]

print(reverse_string("Hello World"))

```

#Question 5

Write a program to find the largest and second largest element in an array.

#Solution 5

```sh

def find_largest_elements(arr):

largest = max(arr[0], arr[1])

second_largest = min(arr[0], arr[1])

for i in range(2, len(arr)):

if arr[i] > largest:

second_largest = largest

largest = arr[i]

elif arr[i] > second_largest:

second_largest = arr[i]

return largest, second_largest

print(find_largest_elements([3, 5, 2, 7, 4, 8, 1]))

```

Dropdown Icon

#Question 2

Write a program to find the Fibonacci series of a given number.

#Solution 2

```sh

def fibonacci(n):

if n <= 0:

return 0

elif n == 1:

return 1

else:

return fibonacci(n-1) + fibonacci(n-2)

print(fibonacci(6))

```

Dropdown Icon

#Question 4

Write a program to reverse a given string

#Answer 4

```sh

def reverse_string(string):

return string[::-1]

print(reverse_string("Hello World"))

```

Dropdown Icon

#Question 3 

Write a program to check if a given number is prime or not.

#Answer 3

```sh

def is_prime(n):

if n <= 1:

return False

for i in range(2, n):

if n % i == 0:

return False

return True

print(is_prime(7))

```

Dropdown Icon

#Question 1

Write a program to find the factorial of a given number

#Solution 1

```sh

def factorial(n):

if n == 0:

return 1

else:

return n * factorial(n-1)

print(factorial(5))

```

Dropdown Icon

#Question 5

Write a program to find the largest and second largest element in an array.

#Solution 5

```sh

def find_largest_elements(arr):

largest = max(arr[0], arr[1])

second_largest = min(arr[0], arr[1])

for i in range(2, len(arr)):

if arr[i] > largest:

second_largest = largest

largest = arr[i]

elif arr[i] > second_largest:

second_largest = arr[i]

return largest, second_largest

print(find_largest_elements([3, 5, 2, 7, 4, 8, 1]))

```

Dropdown Icon
Dropdown Icon
Dropdown Icon
Dropdown Icon
Dropdown Icon

#Question 1

A solid cube of 10 cm x 10cm x 10 cm rests on the ground.  It has a beetle on it, and some sweet honey spots at various locations on the surface of the cube.  The beetle starts at a point on the surface of the cube, and goes to the honey spots in order along the surface of the cube.

#Problem Description

A solid cube of 10 cm x 10cm x 10 cm rests on the ground.  It has a beetle on it, and some sweet honey spots at various locations on the surface of the cube.  The beetle starts at a point on the surface of the cube, and goes to the honey spots in order along the surface of the cube.

1. If it goes from a point to another point on the same face (say X to Y), it goes in an arc of a circle that subtends an angle of 60 degrees at the centre of the circle

2.If it goes from one point to another on a different face, it goes by the shortest path on the surface of the cube, except that it never travels along the bottom of the cube

The beetle is a student of Cartesian geometry, and knows the coordinates (x, y, z) of all the points it needs to go to.  The origin of coordinates it uses is one corner of the cube on the ground, and the z axis points up.  Hence, the bottom surface (on which it does not crawl) is z=0, and the top surface is z=10.  The beetle keeps track of all the distances travelled, and rounds the distance travelled to two decimal places once it reaches the next spot, so that the final distance is a sum of the rounded distances from spot to spot.

#Input

```sh

The first line gives an integer N, the total number of points (including the starting point) the beetle visits

The second line is a set of 3N comma separated non-negative numbers, with up to two decimal places each.  These are to be interpreted in groups of three as the x, y, z coordinates of the points the beetle needs to visit in the given order.

```

#Output

```sh

One line with a number giving the total distance travelled by the beetle accurate to two decimal places.  Even if the distance travelled is an integer, the output should have two decimal places.

```

#Constraints

```sh

None of the points the beetle visits is on the bottom face (z=0) or on any of the edges of the cube (the lines where two faces meet)

2<=N<=10

```

Dropdown Icon

#Question 3

In the theory of numbers, square free numbers have a special place.  A square free number is one that is not divisible by a perfect square (other than 1).

#Problem Description

In the theory of numbers, square free numbers have a special place.  A square free number is one that is not divisible by a perfect square (other than 1).  Thus 72 is divisible by 36 (a perfect square), and is not a square free number, but 70 has factors 1, 2, 5, 7, 10, 14, 35 and 70.  As none of these are perfect squares (other than 1), 70 is a square free number.

For some algorithms, it is important to find out the square free numbers that divide a number.  Note that 1 is not considered a square free number. 

In this problem, you are asked to write a program to find the number of square free numbers that divide a given number.

#Input

```sh

The only line of the input is a single integer N which is divisible by no prime number larger than 19

```

#Output

```sh

One line containing an integer that gives the number of square free numbers (not including 1)

```

#Constraints

```sh

N   < 10^9

```

Dropdown Icon

#Question 2

The parcel section of the Head Post Office is in a mess.  The parcels that need to be loaded to the vans have been lined up in a row in an arbitrary order of weights.  The Head Post Master wants them to be sorted in the increasing order of the weights of the parcels, with one exception.  He wants the heaviest (and presumably the most valuable) parcel kept nearest his office.

#Problem Description

The parcel section of the Head Post Office is in a mess.  The parcels that need to be loaded to the vans have been lined up in a row in an arbitrary order of weights.  The Head Post Master wants them to be sorted in the increasing order of the weights of the parcels, with one exception.  He wants the heaviest (and presumably the most valuable) parcel kept nearest his office.

 You and your friend try to sort these boxes and you decide to sort them by interchanging two boxes at a time.  Such an interchange needs effort equals to the product of the weights of the two boxes. 

The objective is to reposition the boxes as required with minimum effort.

#Input

```sh

The first line consists of two space separated positive integers giving the number of boxes (N) and the position of the Head Post Masters office (k) where the heaviest box must be.

The second line consists of N space separated positive integers giving the weights of the boxes.  You may assume that no two weights are equal.

```

#Output

```sh

The output is one line giving the total effort taken to get the boxes in sorted order, and the heaviest in position k.

```

#Constraints

```sh

N<=50

Weights <= 1000

```

Dropdown Icon
Dropdown Icon
Dropdown Icon
Dropdown Icon
Dropdown Icon
Dropdown Icon

Technical Interview Round Sample Questions 

Here are some examples of technical interview questions that may be asked (entry-level candidates with little or no professional experience):
Can you give an example of a time when you had to work with a team to achieve a common goal?
Dropdown Icon
Coding Question
Dropdown Icon
Coding Question
Dropdown Icon
Coding Question
Dropdown Icon
Coding Question
Dropdown Icon
Coding Question
Dropdown Icon
Explain any coding problems you solved and how you approached that solution.
Dropdown Icon
How do you handle conflicts or difficult situations with colleagues or team members?
Dropdown Icon
How do you handle pressure and tight deadlines?
Dropdown Icon
How do you stay updated on industry trends and new technologies?
Dropdown Icon
Popular Question
Dropdown Icon
Popular Question
Dropdown Icon
Popular Question
Dropdown Icon
What is a linked list?
Dropdown Icon
What is a thread in Java?
Dropdown Icon
What is the difference between an interface and an abstract class in Java?
Dropdown Icon
Which programming language did you use to solve coding problems in Codevita, and why do you prefer that?
Dropdown Icon
Why did you choose TCS as your preferred employer?
Dropdown Icon

HR Interview Round Sample Questions

Here are some examples of technical interview questions that may be asked (entry-level candidates with little or no professional experience):
Can you give an example of a time when you had to work with a team to achieve a common goal?
Dropdown Icon
Coding Question
Dropdown Icon
Coding Question
Dropdown Icon
Coding Question
Dropdown Icon
Coding Question
Dropdown Icon
Coding Question
Dropdown Icon
Explain any coding problems you solved and how you approached that solution.
Dropdown Icon
How do you handle conflicts or difficult situations with colleagues or team members?
Dropdown Icon
How do you handle pressure and tight deadlines?
Dropdown Icon
How do you stay updated on industry trends and new technologies?
Dropdown Icon
Popular Question
Dropdown Icon
Popular Question
Dropdown Icon
Popular Question
Dropdown Icon
What is a linked list?
Dropdown Icon
What is a thread in Java?
Dropdown Icon
What is the difference between an interface and an abstract class in Java?
Dropdown Icon
Which programming language did you use to solve coding problems in Codevita, and why do you prefer that?
Dropdown Icon
Why did you choose TCS as your preferred employer?
Dropdown Icon