TCS NQT 2PM- AUGUST 20TH
1) no
2) puma
3. 18010
4. 2
5. Data in both 1 and 2 are necessary
6. Candidates is not to be selected
7. Harsh
8. UBPJDJQU
9 Both A and R is true BUT R is not correct explain of A
10.
Both A and R are true and R is correct explanation of A
1) no
2) puma
3. 18010
4. 2
5. Data in both 1 and 2 are necessary
6. Candidates is not to be selected
7. Harsh
8. UBPJDJQU
9 Both A and R is true BUT R is not correct explain of A
10.
Both A and R are true and R is correct explanation of A
N=int(input())
K=int(input())
price=list(map(int,input().split()))
vol=list(map(int,input().split()))
maxvol=0
volu=0
maxvol=max(vol)
for i in range(0,N):
if (maxvol==vol[i] and price[i]<=K):
K=K-price[i]
volu=maxvol
for i in range(0,N):
for j in range(i+1,N+1):
if (price[i]<=K and price[i]==price[j]):
if (vol[i]>vol[j]):
volu=volu+vol[i]
K=K-price[i]
else:
volu=volu+vol[j]
K=K-price[j]
elif (price[i]<=K and price[i]!=price[j]):
K=K-price[i]
volu=volu+vol[i]
print(volu)
K=int(input())
price=list(map(int,input().split()))
vol=list(map(int,input().split()))
maxvol=0
volu=0
maxvol=max(vol)
for i in range(0,N):
if (maxvol==vol[i] and price[i]<=K):
K=K-price[i]
volu=maxvol
for i in range(0,N):
for j in range(i+1,N+1):
if (price[i]<=K and price[i]==price[j]):
if (vol[i]>vol[j]):
volu=volu+vol[i]
K=K-price[i]
else:
volu=volu+vol[j]
K=K-price[j]
elif (price[i]<=K and price[i]!=price[j]):
K=K-price[i]
volu=volu+vol[i]
print(volu)
#include<stdio.h>
int main()
{
int n;
scanf("%d",&n);
int arr[n];
for(int i=0;i<n;i++)
{
scanf("%d",&arr[i]);
}
int count=0;
int num=arr[0];
for(int i=1;i<n;i++)
{
if(num!=arr[i])
count++;
}
printf("%d",count);
}
C Language
TCS 1st Qsn
Vijays code
Telegram - https://t.me/nqt_0
int main()
{
int n;
scanf("%d",&n);
int arr[n];
for(int i=0;i<n;i++)
{
scanf("%d",&arr[i]);
}
int count=0;
int num=arr[0];
for(int i=1;i<n;i++)
{
if(num!=arr[i])
count++;
}
printf("%d",count);
}
C Language
TCS 1st Qsn
Vijays code
Telegram - https://t.me/nqt_0
arr=[-1,18,13,18,-2,-16,7,-1,-213,11]
n=len(arr)
maxi=[0]
maxlen=[0]
def fuct(index,s,p):
if index>=n:
if len(p)>maxlen[0]:
maxlen[0]=len(p)
maxi[0]=max(maxi[0],s)
return
else:
if p==[]:
fuct(index+1,s+arr[index],p+[arr[index]])
fuct(index+1,s,p)
else:
if p[-1]>0:
if arr[index]<0:
fuct(index+1,s+arr[index],p+[arr[index]])
else:
fuct(index+1,s,p)
else:
if arr[index]>0:
fuct(index+1,s+arr[index],p+[arr[index]])
else:
fuct(index+1,s,p)
return
fuct(0,0,[])
print(maxi)
n=len(arr)
maxi=[0]
maxlen=[0]
def fuct(index,s,p):
if index>=n:
if len(p)>maxlen[0]:
maxlen[0]=len(p)
maxi[0]=max(maxi[0],s)
return
else:
if p==[]:
fuct(index+1,s+arr[index],p+[arr[index]])
fuct(index+1,s,p)
else:
if p[-1]>0:
if arr[index]<0:
fuct(index+1,s+arr[index],p+[arr[index]])
else:
fuct(index+1,s,p)
else:
if arr[index]>0:
fuct(index+1,s+arr[index],p+[arr[index]])
else:
fuct(index+1,s,p)
return
fuct(0,0,[])
print(maxi)