from itertools import permutations
def count(arr):
z=[]
perm = permutations(arr)
for i in list(perm):
z.append(list(i))
q=[]
for i in range(len(arr)-1):
x,y=arr[i],arr[i+1]
for j in range(len(z)):
if z[j].index(x)!=len(z[j])-1:
if z[j][z[j].index(x)+1]==y:
q.append(z[j])
for i in range(len(q)):
if q[i] in z:
z.remove(q[i])
return len(z)
a= int(input())
b=list(map(int,input().strip().split()))
print(count(b))
Python
Telegram - t.me/codingsolution_IT
def count(arr):
z=[]
perm = permutations(arr)
for i in list(perm):
z.append(list(i))
q=[]
for i in range(len(arr)-1):
x,y=arr[i],arr[i+1]
for j in range(len(z)):
if z[j].index(x)!=len(z[j])-1:
if z[j][z[j].index(x)+1]==y:
q.append(z[j])
for i in range(len(q)):
if q[i] in z:
z.remove(q[i])
return len(z)
a= int(input())
b=list(map(int,input().strip().split()))
print(count(b))
Python
Telegram - t.me/codingsolution_IT
if (n > k && n > a)
{
printf("N is the Biggest number is %d", n);
return n;
}
if (k > n && k > a)
{
printf("k is the Biggest number is %d", k);
return k;
}
if (a > n && a > k)
{
printf("a is the Biggest number is %d", a);
return a;
}
Telegram - t.me/codingsolution_IT
{
printf("N is the Biggest number is %d", n);
return n;
}
if (k > n && k > a)
{
printf("k is the Biggest number is %d", k);
return k;
}
if (a > n && a > k)
{
printf("a is the Biggest number is %d", a);
return a;
}
Telegram - t.me/codingsolution_IT
#include <bits/stdc++.h>
using namespace std;
int count(string s)
{
int N, i, cnt = 0, ans = 0;
N = s.length();
for (i = 0; i < N; i++) {
if (s[i] == 'R')
cnt++;
if (s[i] == 'L')
ans += cnt;
}
return ans;
}
int main()
{
string s = "RRLL";
cout << count(s) << endl;
return 0;
}
C++
Telegram - t.me/codingsolution_IT
using namespace std;
int count(string s)
{
int N, i, cnt = 0, ans = 0;
N = s.length();
for (i = 0; i < N; i++) {
if (s[i] == 'R')
cnt++;
if (s[i] == 'L')
ans += cnt;
}
return ans;
}
int main()
{
string s = "RRLL";
cout << count(s) << endl;
return 0;
}
C++
Telegram - t.me/codingsolution_IT
def getLargestString(s, k):
frequency_array = [0] * 26
for i in range(len(s)):
frequency_array[ord(s[i]) -
ord('a')] += 1
ans = ""
i = 25
while i >= 0:
if (frequency_array[i] > k):
temp = k
st = chr( i + ord('a'))
while (temp > 0):
ans += st
temp -= 1
frequency_array[i] -= k
j = i - 1
while (frequency_array[j] <= 0 and
j >= 0):
j -= 1
if (frequency_array[j] > 0 and
j >= 0):
str1 = chr(j + ord( 'a'))
ans += str1
frequency_array[j] -= 1
else:
break
elif (frequency_array[i] > 0):
temp = frequency_array[i]
frequency_array[i] -= temp
st = chr(i + ord('a'))
while (temp > 0):
ans += st
temp -= 1
else:
i -= 1
return ans
if name == "main":
S = input()
k = 3
print (getLargestString(S, k))
Python
Bob Play The Word Code
Telegram - t.me/codingsolution_IT
frequency_array = [0] * 26
for i in range(len(s)):
frequency_array[ord(s[i]) -
ord('a')] += 1
ans = ""
i = 25
while i >= 0:
if (frequency_array[i] > k):
temp = k
st = chr( i + ord('a'))
while (temp > 0):
ans += st
temp -= 1
frequency_array[i] -= k
j = i - 1
while (frequency_array[j] <= 0 and
j >= 0):
j -= 1
if (frequency_array[j] > 0 and
j >= 0):
str1 = chr(j + ord( 'a'))
ans += str1
frequency_array[j] -= 1
else:
break
elif (frequency_array[i] > 0):
temp = frequency_array[i]
frequency_array[i] -= temp
st = chr(i + ord('a'))
while (temp > 0):
ans += st
temp -= 1
else:
i -= 1
return ans
if name == "main":
S = input()
k = 3
print (getLargestString(S, k))
Python
Bob Play The Word Code
Telegram - t.me/codingsolution_IT