๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
9.61K subscribers
5.59K photos
3 videos
95 files
10.2K 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
#include<bits/stdc++.h>
using namespace std;

int alphaBitwise(vector<int>& A) {
    int N = A.size();
    int result = 0;

    for (int i = 0; i < 32; i++) {
        int count = 0;
        for (int num : A) {
            if ((num >> i) & 1) {
                count++;
            }
        }
        if (count > N / 2) {
            result |= (1 << i);
        }
    }

    return result;
}

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }

    int alpha = alphaBitwise(A);
    cout << alpha << endl;

    return 0;
}

Alpha bitwiseโœ…
๐Ÿ‘1
int calculateMaxLength(vector<int> &values) {
    vector<int> longestIncreasingSubsequence;
    int currentIndex = 1, size = values.size();
    longestIncreasingSubsequence.push_back(values[0]);

    while (currentIndex < size) {
        if (values[currentIndex] < longestIncreasingSubsequence.back()) {
            if (currentIndex == size - 1 || values[currentIndex] + longestIncreasingSubsequence.back() <= values[currentIndex + 1]) {
                longestIncreasingSubsequence.back() += values[currentIndex];
                currentIndex++;
            } else {
                values[currentIndex + 1] += values[currentIndex];
                currentIndex++;
            }
        } else {
            longestIncreasingSubsequence.push_back(values[currentIndex]);
            currentIndex++;
        }
    }

    return longestIncreasingSubsequence.size();
}

Non Decreasing Array โœ…
#include <iostream>
#include <string>
#include <vector>
#include <set>

using namespace std;

void generate_strings(vector<string>& strings, string prefix, int remaining) {
    if (remaining == 0) {
        strings.push_back(prefix);
        return;
    }
    generate_strings(strings, prefix + '0', remaining - 1);
    generate_strings(strings, prefix + '1', remaining - 1);
}

bool is_substring(const string& input_string, const string& substring) {
    for (int i = 0; i < input_string.length(); ++i) {
        string rotated_string = input_string.substr(i) + input_string.substr(0, i);
        if (rotated_string.find(substring) != string::npos) {
            return true;
        }
    }
    return false;
}

int count_distinct_strings(const string& str, int N) {
    vector<string> strings;
    generate_strings(strings, "", N);
    set<string> distinct_strings;

    for (const string& s : strings) {
        if (is_substring(s, str)) {
            distinct_strings.insert(s);
        }
    }

    return distinct_strings.size();
}

int main() {
    string str;
    int N;
   
   
  
    cin >> N;
    cin >> str;

    int count = count_distinct_strings(str, N);
    cout << count << endl;

    return 0;
}

Look A Like โœ…
// rat and chesse
#include<bits/stdc++.h>
using namespace std;
int bfs(vector<vector<int>>&grid){
        queue<pair<int,int>>q;
        int dx[4]={0,0,1,-1};
        int dy[4]={1,-1,0,0};
        for(int i=0;i<grid.size();i++){
            for(int j=0;j<grid[0].size();j++){
                if(grid[i][j]==2)q.push({i,j});
            }
        }
        int time=0;
        while(!q.empty()){
            int k=q.size();
            bool found=false;
            while(k--){
                int r=q.front().first,c=q.front().second;
                q.pop();
                grid[r][c]=2;
                for(int i=0;i<4;i++){
                    int row=r+dx[i],col=c+dy[i];
                    if(row>=0&&row<grid.size()&&col>=0&&col<grid[0].size()&&grid[row][col]==1){
                        q.push({row,col});found=true;
                        grid[row][col]=2;
                    }
                }
            }
            if(found)
             time++;
        }
        // check -1
        for(int i=0;i<grid.size();i++){
            for(int j=0;j<grid[0].size();j++){
                if(grid[i][j]==1)return -1;
            }
        }
        return time;
    }
int main(){
    vector<vector<int>>v={{2,1,1},{1,1,0},{0,1,1}};
    cout<<bfs(v);
}
Get the Max productโœ…

#include<bits/stdc++.h>
using namespace std;
int length(string s){
    bool found=false;
    int temp=0;
    for(int i=0;i<s.size();i++){
        if(isdigit(s[i])){
            found=true;
            temp*=10;
            temp+=(s[i]-'0');
        }
    }
    if(found==false){
        return s.size();
    }
    return temp;
}
long long  solve(vector<string>v,int n){
    vector<int>len;
    for(int i=0;i<n;i++){
        len.push_back(length(v[i]));
    }
    int max1=0,max2=0;
    for(int i=0;i<n;i++){
        if(len[i]>max1){
             max2=max1;
            max1=len[i];
        }
        else if(len[i]>max2){
            max2=len[i];
        }
    }
    return max1*max2*1ll;
    return len[n-1]*len[n-2]*1ll;
}
int main(){
    int n;cin>>n;
    vector<string>v(n,"");
    for(int i=0;i<n;i++)
    {
        cin>>v[i];
    }
    cout<<solve(v,n);
}
#include <bits/stdc++.h>
using namespace std;
   
int main() {
 
  int n;
  cin>>n;
  vector<int> v(100005);
  for(int i = 0; i < n; i++) cin>>v[i];
  int ans = 0;
  int i = n-1;
  while(i >= 0) {
    if(v[i] >= 0) {
      ans += v[i]; i--; continue;
    }
    else {
      v[i] *= -1;
      int y = v[i], x = 0;
      ans += v[i]; i--;
      while(i >= 0 && v[i] >= 0) {
        x += v[i];
        i--;
        if(x >= y) break;
      }
    }
  }
  cout<<ans;

    return 0;
}

Good Sum โœ…
int MinimumCost(int n, int m, vector<vector<int>>& grid) {
    vector<int> ele;

    vector<vector<int>> grid_inv(m, vector<int>(n));

    for (int j = 0; j < m; j += 1) {
        for (int i = 0; i < n; i += 1) {
            grid_inv[j][i] = grid[i][j];
        }
    }

    for (int j = 0; j < m; j += 1) {
        sort(grid_inv[j].begin(), grid_inv[j].end());
    }

    for (int i = 0; i < n; i += 1) {
        for (int j = 0; j < m; j += 1) {
            ele.push_back(grid[i][j]);
        }
    }

    sort(ele.begin(), ele.end());

    int sz = ele.size();

    int ans = 1e9; // Assuming int limit is sufficient for ans

    for (int i = 0; i < ele.size(); i += 1) {
        int mx = ele[i];
        bool f = 1;
        int mn = 1e9; // Assuming int limit is sufficient for mn
        for (int j = 0; j < m; j += 1) {
           int idx = lower_bound(grid_inv[j].begin(), grid_inv[j].end(), mx) - grid_inv[j].begin();
           if (idx >= n || grid_inv[j][idx] > mx) idx--;
           if (idx < 0) {
            f = 0;
            break;
           }
           mn = min(mn, grid_inv[j][idx]);
        }

        if (f) ans = min(ans, mx - mn);
    }

    return ans;
}

Minimum Cost pathโœ…
int solve(string S) {
    set<int> decimalValues;
    int n = S.length();
   
    for (int i = 1; i < (1 << n); i++) {
        int subsequenceDecimal = 0;
        for (int j = 0; j < n; j++) {
            if (i & (1 << j)) {
                subsequenceDecimal = subsequenceDecimal * 2 + (S[j] - '0');
            }
        }
        decimalValues.insert(subsequenceDecimal);
    }
   
    int distinctDecimalValues = decimalValues.size();
    int moduloResult = distinctDecimalValues % (int)(1e9 + 7);
    return moduloResult;
}

Distinct Subsequenceโœ…
int countKSubsequencesWithMaxBeauty(string s, int k) {
    vector<int> count(26);
    for (char& c : s)
        count[c - 'a']++;
    
    nth_element(count.begin(), count.begin() + 26 - k, count.end());
    
    if (k > 26 || count[26 - k] == 0)
        return 0;
    
    long long res = 1, comb = 1, bar = count[26 - k], mod = 1e9 + 7, pend = 0;
    
    for (int& freq : count) {
        if (freq > bar) {
            k--;
            res = res * freq % mod;
        }
        if (freq == bar)
            pend++;
    }
    
    for (int i = 0; i < k; ++i) {
        comb = comb * (pend - i) / (i + 1);
        res = res * bar % mod;
    }
    
    return res * comb % mod;
}

GOOGLE SPECIAL-SUBSEQUENCE CODE
๐Ÿ‘1๐Ÿคฎ1
Sutherland Walk-In Interview

1st October โ€“ 6th October , 9.30 AM โ€“ 5.30 PM

How to Apply:

Interested candidates are invited to attend a walk-in interview. Please mention โ€œHR Priyaโ€ at the top of your resume. Donโ€™t forget to bring your resume, a photocopy of your Aadhar card, and your COVID-19 vaccination certificate (2/3 doses).

Walk-in Details:

Date: October 1st โ€“ October 6th
Time: 9:30 AM โ€“ 5:30 PM
Location: Survey No. 201, Lanco Hills Technology Park, Lanco Hills, Sai Vaibhav Layout, Manikonda, Hyderabad, 500089, India.

Contact Information: For inquiries, contact Priya at 9032420290.