Code With Virus
9.37K subscribers
1.39K photos
2 videos
10 files
679 links
Coding channel @codewithvirus. πŸ‘ˆ

Main group @avirustech πŸ‘ˆ

Accenture @Accenturavirustech πŸ‘ˆ

IBM. @IBMavirustech πŸ‘ˆ

Tech Mahindra. @TechMavirustech πŸ‘ˆ
Download Telegram
Who have Infosys SP and DSP roll exam ??

And what's your exam time??

https://bit.ly/codewithanusha

https://bit.ly/infosys-SP-DSP
πŸ‘1
// Infosys
//Given Array A having N integers and divisor K
int morethanNbyK(vector<int> arr, int n, int k)
{
    int x = n / k;
    int ans = 0;
    unordered_map<int, int> freq;
    for (auto i : arr)
        freq[i]++;
    for (auto i : freq)
    {
        if (i.second > x)
        {
            ans += i.first;
        }
    }
    return ans;
}
// @codewithvirus
// @codewithvirus
// @codewithvirus
// @codewithvirus

https://bit.ly/infosys-SP-DSP
// Infosys
// N flowers on a Recatangular pana
int ans = 100000000;
void solve(vector<int> a, int n, int k, int index, int sum,
           int maxsum)
{
    if (k == 1)
    {
        maxsum = max(maxsum, sum);
        sum = 0;
        for (int i = index; i < n; i++)
        {
            sum += a[i];
        }
        maxsum = max(maxsum, sum);
        ans = min(ans, maxsum);
        return;
    }
    sum = 0;
    for (int i = index; i < n; i++)
    {
        sum += a[i];
        maxsum = max(maxsum, sum);
        solve(a, n, k - 1, i + 1, sum, maxsum);
    }
}
int GetMaxBeauty(int N, int K, vector<int> A)
{

    solve(A, N, K, 0, 0, 0);
    return ans;
}

// @codewithvirus
// @codewithvirus
// @codewithvirus
// @codewithvirus

https://bit.ly/infosys-SP-DSP
πŸ‘3
Infosys
C++ language
@codewithvirus

You are given a string S of length N. You can erase any substring of S of size <N. You need to return the lexicographically smallest remaining string after erasing a substring of S.

https://bit.ly/infosys-SP-DSP
πŸ‘2
You are given a pair of string A and B of length N
Infosys
@codewithvirus

https://bit.ly/infosys-SP-DSP
πŸ‘2
You are given a string S with length N and a number K

For every substring from s with length K we will get all permutations of this substring, This means that if k=3, all permutations of the substring aab are aab aba, baa.

Count the total number of distinct strings in all permatetions of all substrings of S with length K, Since the answer may be very large return it modulo 1000000007


Notes:
If we have the string ab, bb, ab, ba, there are 3 distinct strings ab, bb, and ba

Input Format
The first line contains an integer, N, denoting the lehorn of the given string.
The next line contains an integer, K, denoting the length of each substring.
The next line contains a string, S, denoting the given string

int f(int n) {
int r = 1;
for (int i = 2; i <= n; i++) {
r = (r * i) % MOD;
}
return r;
}
int functionName(int N,int K, string s)
{
int r = 0;
for (int i = 0; i <= N - K; i++) {
unordered_map<char, int> c;
for (int j = i; j < i + K; j++) {
c[S[j]]++;
}
int p = 1;
for (auto count : c) {
p = (p * f(count.second)) % MOD;
}
r = (r + f(K) / p) % MOD;
}
return r;
}


Language c++
Infosys
@codewithvirus
@codewithvirus
@codewithvirus
https://bit.ly/infosys-SP-DSP
πŸ‘2