๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
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
L&T Technology Services - MBA Intern Hiring โ€“ 2024 or 2025 pass out batch.

Please register using the below link: https://forms.office.com/pages/responsepage.aspx?id=eDMbMYqOXkujP-gKPYumClSsrm1sEv1BmOXg5_0vsfxUOUY2WUU1MUpRWlBROUtMSFFaSDRSOFZHRi4u

** Please note that applicants that do not fill the above form will not be considered.
Registration End Date: 6:00PM, 31st July 2024

Type: Full time Offline Internship
Location:  Mysore
Specialization:  B. Tech + Mba in Sales & Marketing
Year of Pass out: Batch of 2024 or 2025
Stipend: As per Industry Standards

Job Brief:
    - A Presales Intern acts as a bridge between the sales and technical teams, providing valuable insights and solutions to potential clients.
    -  This role involves a strategic approach to understanding client needs and aligning product or service offerings accordingly.

Requirement and Skills:
    - Excellent communication and presentation skills.
    - Strong analytical and problem-solving abilities.
    - Ability to work collaboratively in a fast-paced and dynamic environment.
๐Ÿ˜ฑ1
#include <iostream> 
#include <vector>

using namespace std;

// Function to find the bitwise OR of sums of all sub-sequences
int bitwiseOrOfSums(const vector<int>& arr) {
    int result = 0;
    for (int num : arr) {
        result |= num;
    }
    return result;
}

int main() {
    int T;
    cin >> T;
    
    while (T--) {
        int N;
        cin >> N;
        vector<int> arr(N);
        
        for (int i = 0; i < N; ++i) {
            cin >> arr[i];
        }
        
        cout << bitwiseOrOfSums(arr) << endl;
    }
    
    return 0;
}

Unify โœ…
import math

def main(input):
    minutes = int(input)
    radius = minutes * 60
    area = 3.14 * (radius ** 2)
    result = math.floor(area)
    print(result)

if __name__ == "__main__":
    user_input = input().strip()
    main(user_input)

Fire in the forest
Unify โœ…
โค1
#include <iostream>
#include <vector>
using namespace std;
int main() {
    int N, Q;
    cin >> N >> Q;
    vector<int> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }

    vector<int> results(Q);
    for (int q = 0; q < Q; ++q) {
        int L, R, X;
        cin >> L >> R >> X;
        --L;
        --R;
        long long sumXor = 0;
        for (int i = L; i <= R; ++i) {
            sumXor += (A[i] ^ X);
        }
        results[q] = sumXor;
    }
    for (const auto& res : results) {
        cout << res << endl;
    }

    return 0;
}


The XOR Operation โœ…
Unify
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
Photo
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int maxReward(const vector<int>& reward_1, const vector<int>& reward_2, int k) {
    int n = reward_1.size();
    vector<pair<int, int>> diffs(n);
    for (int i = 0; i < n; ++i) {
        diffs[i] = {reward_1[i] - reward_2[i], i};
    }
        sort(diffs.rbegin(), diffs.rend());
   
    int aa = 0;
        for (int i = 0; i < k; ++i) {
        aa += reward_1[diffs[i].second];
    }
   
    for (int i = k; i < n; ++i) {
        aa += reward_2[diffs[i].second];
    }
   
    return aa;
}

Atlassian โœ…
๐Ÿ‘2
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
Photo
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <climits>
using namespace std;
int solve(int center_nodes, int center_edges, vector<int>& center_from, vector<int>& center_to, vector<int>& status) {
    vector<vector<int>> graph(center_nodes);
    for (int i = 0; i < center_edges; ++i) {
        int u = center_from[i] - 1;
        int v = center_to[i] - 1;
        graph[u].push_back(v);
        graph[v].push_back(u);
    }

    queue<pair<int, int>> q;
    vector<int> min_time(center_nodes, INT_MAX);
    for (int i = 0; i < center_nodes; ++i) {
        if (status[i] == 3) {
            q.push({i, 0});
            min_time[i] = 0;
        }
    }
    while (!q.empty()) {
        int node = q.front().first;
        int time = q.front().second;
        q.pop();

        for (int neighbor : graph[node]) {
            if (min_time[neighbor] > time + 1) {
                min_time[neighbor] = time + 1;
                q.push({neighbor, time + 1});
            }
        }
    }
    int max_time = 0;
    for (int i = 0; i < center_nodes; ++i) {
        if (status[i] == 1) {
            if (min_time[i] == INT_MAX) {
                return -1;
            }
            max_time = max(max_time, min_time[i]);
        }
    }

    return max_time;
}

Atlassian โœ…
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
Photo
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <climits>
using namespace std;
vector<int>solve(vector<int>& cost, vector<string>& aa) {
    int n = cost.size();
    vector<int> result(n, -1);
    vector<int> costA, costB, costBoth;
        for (int i = 0; i < n; ++i) {
        if (aa[i] == "10") {
            costA.push_back(cost[i]);
        } else if (aa[i] == "01") {
            costB.push_back(cost[i]);
        } else if (aa[i] == "11") {
            costBoth.push_back(cost[i]);
        }
    }
    sort(costA.begin(), costA.end());
    sort(costB.begin(), costB.end());
    sort(costBoth.begin(), costBoth.end());
   
    vector<int> prefixA(costA.size() + 1, 0);
    vector<int> prefixB(costB.size() + 1, 0);
    vector<int> prefixBoth(costBoth.size() + 1, 0);
   
    for (int i = 0; i < costA.size(); ++i) prefixA[i + 1] = prefixA[i] + costA[i];
    for (int i = 0; i < costB.size(); ++i) prefixB[i + 1] = prefixB[i] + costB[i];
    for (int i = 0; i < costBoth.size(); ++i) prefixBoth[i + 1] = prefixBoth[i] + costBoth[i];
   
    for (int k = 1; k <= n; ++k) {
        int minCost = INT_MAX;
                for (int i = 0; i <= min(k, (int)costBoth.size()); ++i) {
            if (k - i <= (int)costA.size() && k - i <= (int)costB.size()) {
                int currentCost = prefixBoth[i] + prefixA[k - i] + prefixB[k - i];
                minCost = min(minCost, currentCost);
            }
        }
       
        if (minCost != INT_MAX) {
            result[k - 1] = minCost;
        }
    }
   
    return result;
}

Atlassian โœ…
๐Ÿ‘1
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
Photo
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
int bfs(int start, vector<vector<int>>& adj, vector<bool>& visited) {
    queue<int> q;
    q.push(start);
    visited[start] = true;
    int size = 0;
    while (!q.empty()) {
        int node = q.front();
        q.pop();
        size++;
       
        for (int neighbor : adj[node]) {
            if (!visited[neighbor]) {
                visited[neighbor] = true;
                q.push(neighbor);
            }
        }
    }
   
    return size;
}
int solve(int K) {
    vector<int> primes;
    int num = 2;
    while (primes.size() < K) {
        bool is_prime = true;
        for (int i = 2; i * i <= num; i++) {
            if (num % i == 0) {
                is_prime = false;
                break;
            }
        }
        if (is_prime) {
            primes.push_back(num);
        }
        num++;
    }
   
    return primes[K-1];
}

int main() {
    int N, M;
    cin >> N >> M;
    vector<vector<int>> adj(N + 1);
    for (int i = 0; i < M; i++) {
        int U, V;
        cin >> U >> V;
        adj[U].push_back(V);
        adj[V].push_back(U);
    }
    vector<bool> visited(N + 1, false);
    int max_landmarks = 0;
   
    for (int i = 1; i <= N; i++) {
        if (!visited[i]) {
            int component_size = bfs(i, adj, visited);
            max_landmarks = max(max_landmarks, component_size);
        }
    }
    int ticket_price = solve(max_landmarks);
    cout << max_landmarks << " " << ticket_price << endl;
   
    return 0;
}

Texas instrument โœ…
๐Ÿ‘1
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
Photo
#include <iostream>
#include <queue>
#include <vector>
#include <unordered_map>
#include <functional>
#include <algorithm>
using namespace std;
struct Compare {
    bool operator()(const pair<int, int>& a, const pair<int, int>& b) {
        if (a.second == b.second) return a.first > b.first;
        return a.second < b.second;
    }
};

int main() {
    int N;
    cin >> N;
    priority_queue<pair<int, int>, vector<pair<int, int>>, Compare> pq;
    unordered_map<int, int> elementPriority;
    unordered_map<int, bool> removedElements;
    for (int i = 0; i < N; ++i) {
        int x, y;
        cin >> x >> y;
        pq.push({x, y});
        elementPriority[x] = y;
        removedElements[x] = false;
    }

    int K;
    cin >> K;
    for (int i = 0; i < K && !pq.empty(); ++i) {
        int removedElement = pq.top().first;
        pq.pop();
        removedElements[removedElement] = true;
    }

    vector<pair<int, int>> remainingElements;
    for (const auto& entry : elementPriority) {
        if (!removedElements[entry.first]) {
            remainingElements.push_back({entry.first, entry.second});
        }
    }

    sort(remainingElements.begin(), remainingElements.end(), [](const pair<int, int>& a, const pair<int, int>& b) {
        if (a.second == b.second) return a.first < b.first;
        return a.second > b.second;
    });

    for (const auto& el : remainingElements) {
        cout << el.first << endl;
    }

    return 0;
}


Texas instrument โœ…
#include <iostream>
#include <string>
#include <cctype>
using namespace std;
char encodeChar(char c) {
    if (isalpha(c)) {
        char base = islower(c) ? 'a' : 'A';
        char newChar = base + (c - base + 3) % 26;
        return toupper(newChar);
    }
    return c;
}
string solve(const string& s) {
    string result = s;
    for (size_t i = 1; i < s.length(); i += 2) {
        result[i] = encodeChar(s[i]);
    }
    return result;
}

Encoding โœ…
๐Ÿ‘1
#include <iostream>
#include <string>
using namespace std;
string solve(const string& str1, const string& str2) {
    string result;
        for (size_t i = 0; i < str1.size(); ++i) {
        if (str1[i] != str2[i]) {
            result += str2[i];
        }
    }
   
    return result;
}

int main() {
    string str1, str2;
        cin >> str1 >> str2;
   
    cout << solve(str1, str2) << endl;
   
    return 0;
}


TEXAS 1