allcoding1
22.4K subscribers
2.19K photos
2 videos
77 files
913 links
Download Telegram
Java language

Telegram:- @allcoding1
👍7
Java language

Telegram:- @allcoding1
👍6
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 - @allcoding1
👍25
Java language

Telegram:- @allcoding1
👍6
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:- @allcoding1
👍30
Python

Find Minimum Distance Between two numbers in Array code

Telegram:- @allcoding1
👍7
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 code

Telegram:- @allcoding1
👍40
#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 - @allcoding1
👍141👎1
C++

Question:-
You are given Queries.each query consists of 3 integer X[i],Y[i] and N[i] where i donates the ith query The answer to ith query X[i],Y[i] and N[i] is denoted By (X[i],Y[i])^((X[i]+1),Y[i])^....^((X[i],N[i]*Y[i]) Find the sum of all answers modulo 10^9+7

Telegram:- @allcoding1
👍142
XOR elements
C++ language

Telegram:- @allcoding1
👍1
magic Number Code

python 3

All test cases passed

Telegram:- @allcoding1
👍18
C++

Telegram:- @allcoding1
👍3
C++

Telegram:- @allcoding1
👍3
C++

Telegram:- @allcoding1
👍9