TCS NQT Coding Solve| 10am

MCQ

1. 210-1
2. Queue
3. Stack overflow
4. Default Argument
5. Abstraction
6. Full Binary Tree
7. Equivalance....
8. 11
9. B
10. 294

Question 1:

#Correct solution in Python

x=input()
y=input()
if len(x)>=2 and len(x)<=50:
    if x[0]==x[-1]:
        print(x.count(y))
    else:
        print(0)
else:
    print(-1)
Alternative
//Correct solution in C

#include <stdio.h>
#include<string.h>

int main(void) {
 // your code goes here
 char a[1000],c,vs;
 int i,count=0;
 scanf("%s",a);
 
 scanf("%c",&vs);
 scanf("%c",&c);

 
 
 if(a[i]==a[strlen(a)-1])
 {
     
     for(i=0;a[i]!='\0';i++)
     {
         if(a[i]==c)
             count++;
       // printf("%d",count);
     }
 }
 printf("%d",count);
 return 0;
}

Question 2:

#Correct Solution in Python

x1=input()
x2=input()
a=sorted(x1)
b=sorted(x2)

if a==b:
    print(1)
else:
    print(0)

Follow us

You Missed

Also Checkout