2 849
Subscribers
-424 hours
-147 days
-4630 days
Posts Archive
TCS IRA PYTHON
1, A
2, 2003
3, machine learning
4, 2018
5, AI
6, C
8, A
9, B
10, D
11, D
12, B
13, B
14, A
15, C
@codingsolution_group
@codingsolution_group
@codingsolution_group
Guys share our group screenshot to larger groups.
❤️
@codingsolution_group
@codingsolution_group
@codingsolution_group
TCS IRA
Java IRA
26 - all
27 - id
28 - ol
29 - a and b
30 - before it loads
31- error
32 - false true
33- 35
@codingsolution_group
@codingsolution_group
@codingsolution_group
Tree code
l=list(map(int,input().split(',')))
m=[]
for i in range(5):
k=[]
for j in range(5):
k.append('O')
m.append(k)
for i in l:
a1=(i-1)//5
a2=(i-1)%5
m[a1][a2]='X'
num=0
for i in m:
x=0
o=0
for j in i:
if j=='X':
x=x+1
else:
o=o+1
if x==5:
num=1
if o==5:
num=2
for i in range(5):
x=0
o=0
for j in range(5):
if m[j][i]=='X':
x=x=1
else:
o=o+1
if x==5:
num=1
if o==5:
num=2
o1=0
x1=0
o=0
x=0
for i in range(5):
for j in range(5):
if i==j:
if m[i][j]=='X':
x1=x1+1
else:
o1=o1+1
if i==5-j-1:
if m[i][j]=='X':
x=x+1
else:
o=o+1
if o1==5 or o==5:
num=2
if x1==5 or x==5:
num=1
print(num)
for i in range(5):
for j in range(5):
print(m[i][j],end='')
if j!=4:
print(',',end='')
print()
@codingsolution_group
@codingsolution_group
@codingsolution_group
Minimum strings code
int minStringMoves(char* a, char* b) {
int length, pos, i, j, moves=0;
char *ptr;
length = strlen(a);
for(i=0;i<length;i++) {
// Find the first occurrence of b[i] in a
ptr = strchr(a,b[i]);
pos = ptr - a;
// If its the last element, swap with the first
if(i==0 && pos == length-1) {
swap(&a[0], &a[length-1]);
moves++;
}
// Else swap from current index till pos
else {
for(j=pos;j>i;j--) {
swap(&a[j],&a[j-1]);
moves++;
}
}
// If equal, break
if(strcmp(a,b) == 0)
break;
}
return moves;
}
@codingsolution_group
@codingsolution_group
@codingsolution_group
Longest palindrome
int longestPalindrome(vector<string> a,int n)
{
string pair1[n];
string pair2[n];
int r = 0;
for (int i = 0; i < n; i++) {
string s = a[i];
reverse(s.begin(), s.end());
for (int j = i + 1; j < n; j++) {
if (a[i] != "" && a[j] != "") {
if (s == a[j]) {
pair1[r] = a[i];
pair2[r++] = a[j];
a[i] = "";
a[j] = "";
break;
}
}
}
}
string s1 = "";
for (int i = 0; i < n; i++) {
string s = a[i];
reverse(a[i].begin(), a[i].end());
if (a[i] != "") {
if (a[i] == s) {
s1 = a[i];
break;
}
}
}
string ans = "";
// Update the answer with
// all strings of pair1
for (int i = 0; i < r; i++) {
ans = ans + pair1[i];
}
// Update the answer with
// palindromic string s1
if (s1 != "") {
ans = ans + s1;
}
// Update the answer with
// all strings of pair2
for (int j = r - 1; j >= 0; j--) {
ans = ans + pair2[j];
}
return ans.size();
}
@codingsolution_group
@codingsolution_group
@codingsolution_group
✅Alice code :
def smallest(n):
arr = list()
x = 0
for i in range(n):
x = int(input())
arr.append(x)
arr = sorted(arr)
count = 1
temp = list()
for j in range(1, n):
if arr[j] == arr[j-1] + 1:
count += 1
else:
temp.append(count)
count = 1
temp.append(count)
return min(temp)
n = int(input())
res = smallest(n)
print(res)
def isP(n):
if n<=3:
return True
if ((n%2==0)|(n%3==0)):
return False
for d in range(5,int(n*5)+1,6):
if ((n%d==0)|(n%(d+2)==0)):
return False
return True
def getP(m):
P=[1,2]
for n in range(3,m+1,2):
if isP(n):
P.append(n)
return P
P=getP(int(105+1000))
g = int(input().strip())
for a0 in range(g):
n = int(input().strip())
for i in range(len(P)):
if P[i]>n:
c=i-1
break
if c%2==1:
print("Alice")
else:
print("Bob")
@codingsolution_group
@codingsolution_group
@codingsolution_group
COGNIZANT EXAM SOLUTION GROUP:
✅https://t.me/codingsolution_group
Share Your Queries (Questions) here👇👇
https://t.me/Exam_answer_group
https://t.me/Exam_answer_group
🔥Share our group links to your friends Circle ❤️
