TCS 2020 MOCKVITA

๐†๐ž๐ญ ๐ญ๐ก๐ž ๐Ÿ๐ฎ๐ฅ๐ฅ ๐ช๐ฎ๐ž๐ฌ๐ญ๐ข๐จ๐ง ๐๐ž๐ฌ๐œ๐ซ๐ข๐ฉ๐ญ๐ข๐จ๐ง ,๐๐ข๐ฌ๐œ๐ฎ๐ฌ๐ฌ๐ข๐จ๐ง๐ฌ ๐š๐ง๐ ๐ฌ๐จ๐ฅ๐ฎ๐ญ๐ข๐จ๐ง๐ฌ ๐จ๐Ÿ ๐ญ๐ก๐ž ๐ฆ๐จ๐œ๐ค๐•๐ข๐ญ๐š ๐Ÿ ๐Ÿ๐ŸŽ๐Ÿ๐ŸŽ ๐ก๐ž๐ซ๐ž:

Swayamvar: Swayamvar | TCS MockVita 2 2020 | By CodingHumans

Death Battle: Death Battle | TCS MockVIta 2 2020 | By CodingHumans |

Grooving Monkey: Grooving Monkeys | TCS MockVIta 2 2020 | By CodingHumans |

Petrol Pump: Petrol Pump |TCS MockVIta 2 2020 | By CodingHumans |

Dole CAdbury: Dole Out Cadbury | TCS MockVIta 2 2020 | By CodingHumans |

Digit Pairs: Digit Pairs | TCS MockVIta 2 2020 | By CodingHumans |

import java.util.*;

public class PetrolPump
{
private static int[] StrToInt(String src)
{
String[] t=src.split(" ");
int[] res=new int[t.length];
for (int i=0;i<t.length;i++ )
res[i] = Integer.parseInt(t[i]);
return res ;
}
public static void main(String[] args)
{
Scanner ip=new Scanner(System.in);
int a[]=new int[50];
String vals=ip.nextLine();
a=StrToInt(vals);
int n,m=0;
n=a.length;
for(int k=0;k<n;k++)
m=m+a[k];
int b[][]=new int[n+1][m+1];
int i,j;
for(i=0;i<=n;i++)
b[i][0]=1;
for(i=1;i<=m;i++)
b[0][i]=0;
for(i=1;i<=n;i++)
{
for(j=1;j<=m;j++)
{
b[i][j]=b[i-1][j];
if(a[i-1]<=j)
b[i][j]=b[i][j] | b[i-1][j - a[i-1]];
}
}
int sum=m;
for(i=m/2;i>=0;โ€“i)
{
if(b[n][i]==1)
{
sum=m-i;
break;
}
}
System.out.println(sum);
ip.close();
}
}

For d=16 and v=2, LHS part is not equal to RHS. Before posting anything on the discussion forum, think twice. :slight_smile:

float time,d=pow(x,2)+pow(y,2);
time=sqrt(d)/s;

Sorry my bad. First of all see this distance formula this came from Pythagoras theorem and second equation is about speed = distance/time.
Little suggestion instead of judging others try to focus on yourself first. You have no rights to say โ€œthink before posting something on the discuss forumโ€. We all have mind and we are all sharing our thoughts sometime they may go wrong also. :slight_smile:

1 Like

I am sorry but that wasnโ€™t rude. I expected bit more clear explanation from a four starrer, instead of stating โ€œIts straightforward nothing to explain here. If you see carefully. d/(v * v) = sqrt(d)/sqrt(v * v) = sqrt(d)/vโ€.
Of course, thatโ€™s the formula of time, but your statement is literally stating LHS and RHS are equal. Instead, the explanation should have been like this:
We are supposed to sort based on times. But we should be careful while sorting Floating point values as there is precision loss sometimes. So, instead of taking sqrt(d)/v, we should take d/(v^2) as both are increasing functions and d/(v*2) will be more precise to takeโ€ฆ
I am sorry if I hurted you.:slight_smile:

Brother I said that I am wrong but you sound rude. Ask anybody in this discussion.
And if you are comparing stars here then I clap for you.

Please check time taken both code in picture below.
I tried mockvita 2 question C โ€œDole Out Cadburyโ€, in both python and cpp.
In python

In cpp

Same code in both. Same time complexity.

Bro learn at least 3 languages c(must) / c++(or java) / python for Codevita

Dates for Codevita 2020 announed -

Zone 1 : 8th Aug (3pm) to 9th aug (3pm)
Zone 2 : 15th Aug (3pm) to 16th aug (3pm)

in mockvita round 2 i have solved first four problem so you can guess by comparing my rating and number of question solved by me as a reference i dont have the solution because i have solved it on tcs platform but problem can be of sequence , dp , may be sometime graph but the loved math based question.

surely 2 math problems will be there , one dp and one graph too.

2 Likes

hey @ssrivastava990 after mockvita 2 i am not able to log in it keeps showing log in after 15 mins โ€ฆ

2 Likes

thanks for this. I sat thinking 9th.

hey man weight for starting of codevita . there website is not up to the mark you face problem in login during the contest also so login on there website when you got a mail related to codevita

1 Like