๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
9.52K subscribers
5.56K photos
3 videos
95 files
9.68K 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<iostream>
#include<string>
#include<cmath>

using namespace std;

bool isVowel(char ch) {
    if(ch == 'a' ch == 'e' ch == 'i' ch == 'o' ch == 'u') {
        return true;
    }
    return false;
}

int main() {
    string Str;
    cin >> Str;

    string binaryString = "";
    for(char ch : Str) {
        if(isVowel(ch)) {
            binaryString += '0';
        } else {
            binaryString += '1';
        }
    }
    int decimalValue = 0;
    int n = binaryString.length();

    for(int i = 0; i < n; i++) {
        if(binaryString[i] == '1') {
            decimalValue += pow(2, n - i - 1);
        }
    }
    cout << decimalValue << endl;

    return 0;
}

Providence C++โœ…
๐‚๐จ๐ฆ๐ฉ๐š๐ง๐ฒ ๐๐š๐ฆ๐ž: Unisys

๐‘๐จ๐ฅ๐ž: Associate Development Engineer

๐๐š๐ญ๐œ๐ก ๐ž๐ฅ๐ข๐ ๐ข๐›๐ฅ๐ž: 2021, 2022 and 2023 grads.

https://jobs.unisys.com/us/en/job/REQ549425/Associate-Development-Engineer
#include <bits/stdc++.h>

using namespace std;

vector<long long> palindromes;

long long cal(string p)
{
    string p1 = p;
    reverse(p1.begin(), p1.end());
    p += p1;
    long long ans = 0;
    for (int i = p.size() - 1; i >= 0; i--)
    {
        if (p[i] == '1')
            ans += (1LL << (p.size() - 1 - i));
    }
    return ans;
}

long long cal1(string p)
{
    string p1 = p;
    reverse(p1.begin(), p1.end());
    p1.erase(p1.begin());
    p += p1;
    long long ans = 0;
    for (int i = p.size() - 1; i >= 0; i--)
    {
        if (p[i] == '1')
            ans += (1LL << (p.size() - 1 - i));
    }
    return ans;
}

void f(int idx, string p, int flag)
{
    if (idx == 16)
    {
        palindromes.push_back(cal(p));
        if (!p.empty())
            palindromes.push_back(cal1(p));
        return;
    }
    if (flag == 0)
    {
        f(idx + 1, p, 0);
        f(idx + 1, p + "1", 1);
    }
    else
    {
        f(idx + 1, p + "0", 1);
        f(idx + 1, p + "1", 1);
    }
}

int main()
{
    int t;
    long long idx, ans, n;
    cin >> t;

    f(0, "", 0);
    sort(palindromes.begin(), palindromes.end());

    while (t--)
    {
        cin >> n;
        idx = lower_bound(palindromes.begin(), palindromes.end(), n) - palindromes.begin();
        ans = palindromes[idx] - n;
        if (idx > 0)
            ans = min(ans, n - palindromes[idx - 1]);
        cout << ans << endl;
    }

    return 0;
}

Binary palindrome number โœ