๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
9.63K subscribers
5.61K photos
3 videos
95 files
10.6K links
๐ŸšฉMain Group - @SuperExams
๐Ÿ“Job Updates - @FresherEarth

๐Ÿ”ฐAuthentic Coding Solutions(with Outputs)
โš ๏ธDaily Job Updates
โš ๏ธHackathon Updates & Solutions

Buy ads: https://telega.io/c/cs_algo
Download Telegram
string changeCase(string s, int n)
{
    int n = s.size();
    string ans = "";
    if (n == 1)
    {
        for (int i = 0; i < n; i++)
        {
            int a = 0;
            if (s[i] == ' ')
                a = 1;
            else if (a == 1)
                ans += toupper(s[i]);
            else
                ans += s[i];
        }
    }
    else if (n == 2)
    {
        for (int i = 0; i < n; i++)
        {
            int a = 0;
            if (s[i] == ' ')
                ans += '-';
            else
                ans += s[i];
        }
    }
    else if (n == 3)
    {
        for (int i = 0; i < n; i++)
        {
            int a = 0;
            if (s[i] == ' ')
                ans += '_';
            else
                ans += s[i];
        }
    }
    else if (n == 4)
    {
        ans += toupper(s[0]);
        for (int i = 1; i < n; i++)
        {
            int a = 0;
            if (s[i] == ' ')
                a = 1;
            else if (a == 1)
                ans += toupper(s[i]);
            else
                ans += s[i];
        }
    }
    return ans;
}

Case Styling
IBM C++โœ…
๐Ÿ‘1
int findMaxmumGreyness(vector<string> grid)
{
    int n = grid.size();
    int m = grid[0].length();
    vector<int> one_row(n, 0);
    vector<int> one_col(m, 0);
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            if (grid[i][j] == '1')
            {
                one_row[i]++;
                one_col[j]++;
            }
        }
    }
    int ans = -1e9;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            int ans2 = one_row[i] + one_col[j] - (n + m - one_row[i] - one_col[j]);
            ans = max(ans, ans2);
        }
    }
    return ans;
}

Amazon SDE1
C++โœ…
๐Ÿ‘2
// 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;
}

C++โœ…
๐Ÿ‘1
// 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;
}

infosys-SP-DSP C++โœ…
๐Ÿ‘1
You are given a rooted tree of N vertices and an array A of N integers A[i] is the parent of the vertex (i+1 or 0 if the vertex (i+1) is the root.
For each vertex V from 1 to N, the answer K is the total number of subsets of vertices with the LCA (lowest common ancestor) equal to V Since the of K can be large calculate it modulo 10 ^ 9 + 7
Let there be an integer array Res where Res[i] contains the answer for (I + 1)th  vertex, Find the array Res
Notes:
โ€ข The lowest common ancestor (LCA) is defined for X nodes A1, A2,.... Ax as the lowest node in the tree that has all A1 A2..... Ax as descendants (where we allow a node to be a descendant of itself)

Input Formate
The first line contains an integer N denoting the number of elements in A
Each line 1 of the N subsequent lines (where 0<=i<N) contains an integer
describing All It is given that A[i] denotes the parent of the vertex (i+1) or 0
If the vertex (i+1) is the root

const int N = 100005;
const int MOD = 1e9 + 7;
int  a[N], dp[N], res[N];
vector<int> g[N];
void dfs(int u) {
    dp[u] = 1;
    for (int v : g[u]) {
        dfs(v);
        dp[u] = 1ll * dp[u] * (dp[v] + 1) % MOD;
    }
    res[u] = (1ll * dp[u] * (1 << g[u].size()) - 1 + MOD) % MOD;
}

vector<int> functionName(int n,vector<int>A)
{
    g=A;
    dfs(1);
    return res;
}
  
Language c++โœ…
Infosys
๐Ÿ‘4