Coding | EXAMS | IBM ACCENTURE | VIRTUSA | IBM | AMAZON | TCS | EPAM | WILEY EDGE | TECH MAHINDRA | JPMORGAN | HCL | WIPRO
3.37K subscribers
1.13K photos
3 videos
17 files
373 links
Main channel https://t.me/Coding_000
Contact Admin šŸ‘‰ @ILOVEU_143 for booking your exam slots
Web- https://coding000.github.io/Projects/
šŸ’Æ% clearance in any placement exams
OffCampus -https://t.me/Offcampus_000
Discussion- https://t.me/exams_discussion
Download Telegram
Who have Infosys exam guys??

Join this group and share our channel i will share all codes šŸ˜ŠšŸ‘Øā€šŸ’»

@CODING_000šŸ‘Øā€šŸ’»šŸ˜Š
https://t.me/Coding_000 šŸ‘Øā€šŸ’»šŸ†“
https://t.me/Coding_000 šŸ‘Øā€šŸ’»šŸ†“
https://t.me/Coding_000 šŸ‘Øā€šŸ’»šŸ†“
https://t.me/Coding_000 šŸ‘Øā€šŸ’»šŸ†“

Share āœ… share āœ… share āœ…
šŸ‘2
Join this group and share our channel i will share all Infosys codes šŸ˜ŠšŸ‘Øā€šŸ’»

@CODING_000šŸ‘Øā€šŸ’»šŸ˜Š
https://t.me/Coding_000 šŸ‘Øā€šŸ’»šŸ†“
https://t.me/Coding_000 šŸ‘Øā€šŸ’»šŸ†“
https://t.me/Coding_000 šŸ‘Øā€šŸ’»šŸ†“
https://t.me/Coding_000 šŸ‘Øā€šŸ’»šŸ†“

Share āœ… share āœ… share āœ…
šŸ‘3
How many Of u writing Infosys Exam Today ?

Give reactions....ā¤ļø

Based on reactions i will help...āœ…

Otherwise I will sleep..😓

Share our channel make 4.5k šŸŽÆšŸŽÆ

Share @coding_000ā¤ļøāœ…
ā¤9šŸ‘3
Good Sets


int solve(const string& s) {
    vector<int> lc;
    for (int i = 0; i < s.size(); ++i) {
        if (islower(s[i])) {
            lc.push_back(i);
        }
    }

    int m = 0;
    int c = 0;
    int p = -1;
    for (int i : lc) {
        if (p == -1 || s.substr(p + 1, i - p).compare(s.substr(p + 1, i - p)) != 0) {
            c += 1;
        } else {
            c = 1;
        }
        m = max(m, c);
        p = i;
    }

    return m;
}
šŸ”„1
#include <iostream>
#include <unordered_set>
#include <string>
using namespace std;
void generateSubstrings(const string &s, int len, unordered_set<string> &substrings) {
    for (int i = 0; i <= s.size() - len; ++i) {
        substrings.insert(s.substr(i, len));
    }
}

string findMinimalString(const string &s) {
    unordered_set<string> substrings;
    for (int len = 1; ; ++len) {
        substrings.clear();
        generateSubstrings(s, len, substrings);
        string candidate(len, 'a');
        while (true) {
            if (substrings.find(candidate) == substrings.end()) {
                return candidate;
            }
            int pos = len - 1;
            while (pos >= 0 && candidate[pos] == 'z') {
                candidate[pos] = 'a';
                --pos;
            }
            if (pos < 0) break;
            ++candidate[pos];
        }
    }
}

int main() {
    string S;
    cin >> S;
    cout << findMinimalString(S) << endl;
    return 0;
}. 

// Minimal String

Infosys āœ…
šŸ‘3šŸ”„1
#include <iostream>
#include <vector>
using namespace std;
vector<bool> sieve(int max_val) {
    vector<bool> is_prime(max_val + 1, true);
    is_prime[0] = is_prime[1] = false;
    for (int i = 2; i * i <= max_val; ++i) {
        if (is_prime[i]) {
            for (int j = i * i; j <= max_val; j += i) {
                is_prime[j] = false;
            }
        }
    }
    return is_prime;
}

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

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

    vector<bool> is_prime = sieve(max_val);

    int prime_count = 0, composite_count = 0;
    for (int i = 0; i < N; ++i) {
        if (is_prime[A[i]]) {
            prime_count++;
        } else {
            composite_count++;
        }
    }

    int good_pairs = prime_count * composite_count;
    cout << good_pairs << endl;

    return 0;
}.  

find good pairs in array
Infosys āœ…
šŸ‘1šŸ”„1
bool isp(string s){
    int n=s.length();
    for(int i=0;i<n/2;i++){
        if(s[i]!=s[n-i-1]){
            return false;
        }
    }
    return true;
}

int longestString(vector<string>v){
    unordered_map<string,int>mp;
    for(auto x:v){
        mp[x]++;
    }
    int ans=0;
    for(auto x:mp){
      if(x.second>1){
        int k=(x.second)/2;
          ans+=k*(x.first.length()); 
      }
      if(x.second%2!=0){
         mp[x.first]=1;
      }
      else
      mp.erase(x.first);
    }
    int maxi=0;
    for(auto x:mp){
        if(isp(x.first)){
            maxi=max(maxi,(int)x.first.length());
        }
    }
    return ans+maxi;
}

Max palindrome
Infosys āœ…
šŸ‘1šŸ”„1
#include <iostream>
#include <unordered_set>
#include <string>
using namespace std;
void generateSubstrings(const string &s, int len, unordered_set<string> &substrings) {
    for (int i = 0; i <= s.size() - len; ++i) {
        substrings.insert(s.substr(i, len));
    }
}

string findMinimalString(const string &s) {
    unordered_set<string> substrings;
    for (int len = 1; ; ++len) {
        substrings.clear();
        generateSubstrings(s, len, substrings);
        string candidate(len, 'a');
        while (true) {
            if (substrings.find(candidate) == substrings.end()) {
                return candidate;
            }
            int pos = len - 1;
            while (pos >= 0 && candidate[pos] == 'z') {
                candidate[pos] = 'a';
                --pos;
            }
            if (pos < 0) break;
            ++candidate[pos];
        }
    }
}

int main() {
    string S;
    cin >> S;
    cout << findMinimalString(S) << endl;
    return 0;
}. 

Minimal string āœ…

All test cases pass šŸ‘Øā€šŸ’»āœ…
šŸ‘1šŸ”„1🄰1
Give reactions and share our channel to get more solutions

šŸ†“šŸ†“āœ…

Share fast our channel and share ur questiona below..šŸ‘‡šŸ‘‡

https://t.me/exams_discussion
šŸ‘2
Code Name - cost of string s

int solve(const string& S) {
    vector<int> freq(26, 0);
   
    for (char c : S) {
        freq[c - 'a']++;
    }

    int total = 0;

    for (int i = 0; i < 26; ++i) {
        for (int j = i + 1; j < 26; ++j) {
            total += freq[i] * freq[j] * abs(i - j);
        }
    }

    return total;
}


100% Running āœ…āœ…āœ…

Share our channel @coding_000šŸ‘Øā€šŸ’»šŸ˜Š
šŸ”„2šŸ‘1
#include <bits/stdc++.h>
#define int long long
using namespace std;
#define ll long long
vector<vector<ll>> solve(ll n,ll k,vector<ll>&a,vector<ll>&b)
{
    priority_queue<pair<double,pair<ll,ll>>> pq;
    for(int i=0;i<n;i++)
    {
        double x=a[i];
        double y=b[i];
        double dis=sqrt(x+y);
        pq.push({dis,{x,y}});
        if(pq.size()>k)  pq.pop();
    }
    vector<vector<ll>>ans;
    while(!pq.empty())
    {
        ans.push_back({pq.top().second.first,pq.top().second.second});
        pq.pop();
    }
    sort(begin(ans),end(ans));
    return ans;
}
signed main()
{       
        ll n,k; cin>>n>>k;
        vector<ll>a(n),b(n);
        for(ll i=0;i<n;i++) cin>>a[i];
        for(ll i=0;i<n;i++) cin>>b[i];
        vector<vector<ll>>ans=solve(n,k,a,b);
        for(auto it:ans) cout<<it[0]<<" "<<it[1]<<endl;
           
    return 0;
}


Closet K Points

Share our channel fast
@coding_000āœ…
šŸ‘1šŸ”„1
Minimal String Code āœ…

Python3 āœ…

All test cases passedāœ…

Change variables āœ…
šŸ‘2
def is_palindrome(s):
    return s == s[::-1]

def longest_palindrome_from_substrings(A):
    palindromes = []
    pairs = []
    max_single_palindrome = ""

    for s in A:
        if is_palindrome(s):
            palindromes.append(s)
            if len(s) > len(max_single_palindrome):
                max_single_palindrome = s

    for i in range(len(A)):
        for j in range(i + 1, len(A)):
            combined1 = A[i] + A[j]
            combined2 = A[j] + A[i]
            if is_palindrome(combined1):
                pairs.append(combined1)
            if is_palindrome(combined2):
                pairs.append(combined2)

    longest_palindrome = max_single_palindrome
    for p in pairs:
        if len(p) > len(longest_palindrome):
            longest_palindrome = p

    return longest_palindrome



Palindromic Stringāœ…šŸ‘Øā€šŸ’»

Share Our channel Fast @coding_000āœ…
šŸ‘2šŸ”„1