๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
9.58K subscribers
5.59K photos
3 videos
95 files
10K 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 main()
{
    int n;
    cin >> n;
    int even = 0, odd = 0;
    while (n > 0)
    {
        if ((n % 10) % 2 == 0)
            even += n % 10;
        else
            odd += n % 10;
        n = n / 10;
    }
    cout << even * odd;
}

C++โœ…
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int arr[n];
    for (int i = 0; i < n; i++)
    {
        cin >> arr[i];
    }
    int k;
    cin >> k;
    sort(arr, arr + n);
    cout << arr[k - 1];
}

C++โœ…
vvl tree;
vector<bool> todo, good;

void dfs(int v, int p = -1) {
    for (int u : tree[v]) {
        if (u != p) {
            dfs(u, v);
            if (todo[u]) {
                todo[v] = true;
            }
            if (good[u]) {
                good[v] = true;
            }
        }
    }
}

long long findMinimumPathLength(ll n, vvl edges, vll visitNodes) {

    tree = vector<vector<long long>>(n);
    todo = vector<bool>(n);
    good = vector<bool>(n);

    for(long long i = 0; i < edges.size(); i++) {
        tree[edges[i][0] - 1].push_back(edges[i][1] - 1);
        tree[edges[i][1] - 1].push_back(edges[i][0] - 1);
    }

    for(long long i = 0; i < visitNodes.size(); i++) {
        todo[visitNodes[i] - 1] = true;
    }
    good[n - 1] = true;

    dfs(0);
    long long ans = 0;

    for(long long i = 0; i < n; i++) {
        if(i == 0) continue;
        if(good[i]) {
            ans++;
        }
        else if(todo[i]) {
            ans += 2;
        }
    }

    return ans;
}

Nodes in a tree
def find_nearest_cities_3(x_cord, y_cord, city, query_cities):
   
    def distance(x_y1, x_y2):
        x1, y1 = x_y1
        x2, y2 = x_y2
        return abs(x2-x1) + abs(y2-y1)
       
    def b_search_smallest(coord_city_list, target_coord, target_city):
        start, end = 0, len(coord_city_list)-1
        while(start<end):
            mid = start + (end - start)//2
            if coord_city_list[mid][0]>=target_coord:
                end = mid
            else:
                start = mid+1
        returning_city  = coord_city_list[start][1]
        if returning_city == query_city:
            dis_around_query = float('inf')
            if start>0:
                dis_around_query = coord_city_list[start-1][0]
                returning_city =coord_city_list[start-1][1]
            if start<len(coord_city_list)-1 and coord_city_list[start+1][0]<=dis_around_query:
                    dis_around_query = coord_city_list[start+1][0]
                    returning_city =coord_city_list[start+1][1]
        return returning_city
               
   
    x_map, y_map, c_map = defaultdict(list), defaultdict(list), defaultdict()
    for c, x, y in zip(city, x_cord, y_cord):
        x_map[x].append((y, c))
        y_map[y].append((x, c))
        c_map[c]= (x, y)
   
    for k in x_map.keys():
        x_map[k].sort()
        y_map[k].sort()
   
    # print(x_map)
    # print(y_map)
    # print(c_map)
    res = []
    for query_city in query_cities:
        if query_city not in c_map:
            res.append(None)
        else:
            query_x, query_y = c_map[query_city]
            city_near_x = b_search_smallest(x_map[query_x], query_y, query_city)
            city_near_y = b_search_smallest(y_map[query_y], query_x, query_city)
            if city_near_x == query_city and city_near_y == query_city:
                res.append(None)
            elif city_near_x == query_city:
                res.append(city_near_y)
            elif city_near_y == query_city:
                res.append(city_near_x)
            else:
                dist1, dist2 = distance(c_map[query_city], c_map[city_near_x]), distance(c_map[query_city], c_map[city_near_y])
                if dist1<dist2:
                    res.append(city_near_x)
                else:
                    res.append(city_near_y)
    return res

Nearest Neighboring City โœ…
Flipkart is Hiring for #Data Analyst role for #Banglore

Exp- 1-2 yrs (freshers with good analytical skills can also be considered)

Skills - SQL, Tableau/Power BI, Advance Excel & Python

6 Days working(3 days wfh)

Send CV for referral: kaibalya.das@flipkart.com
โค1
Xiaomi Ode2Code 3.0 ๐Ÿš€๐Ÿš€

๐„๐ฅ๐ข๐ ๐ข๐›๐ข๐ฅ๐ข๐ญ๐ฒ ๐‚๐ซ๐ข๐ญ๐ž๐ซ๐ข๐š:

1. This competition is open to students pursuing B.Tech and M.Tech across ALL Engineering Colleges in India. (Batch of 2024, 2025 & 2026)

2. Students must register in teams of 1 to 2 members.

3. The participating students can be from any specialization, 4. Members of a team should be from the same Institute.


๐๐ซ๐จ๐œ๐ž๐ฌ๐ฌ:

1. Online Quiz 1 (August 14th, 2023)

2. Online Quiz 2 (August 17th, 2023)

3. Submission Round (August 21st, 2023)

4. Finale

https://unstop.com/competitions/xiaomi-ode2code-30-xiaomi-india-713806?lb=VM0FqwL&utm_medium=Share&utm_source=shortUrl
๐Ÿ‘1
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
bool prime[100005];
int dp[100005];
ll answer;
bool visited[100005];
vector<int> adjacent[100005];

void dfs1(int u) {
visited[u] = true;
int sum = prime[u] ? 0 : 1;
for (int i = 0; i < adjacent[u].size(); i++) {
int v = adjacent[u][i];

if (!visited[v]) {
dfs1(v);
sum += dp[v];
}
}

dp[u] = sum;

if (prime[u]) dp[u] = 0;
}

void dfs2(int u, int p, int dv) {
visited[u] = true;

if (prime[u]) {
vector<ll> pp;
ll sum = dv;
pp.push_back(dv);
for (int i = 0; i < adjacent[u].size(); i++) {
int v = adjacent[u][i];

if (!visited[v] && v != p) {
dfs2(v, u, 0);
pp.push_back(dp[v]);
sum += dp[v];
}
}

ll val = 0;
for (int i = 0; i < pp.size(); i++) {
val += (sum - pp[i]) * pp[i];
}

val /= 2;
answer += val;
answer += sum;
} else {
for (int i = 0; i < adjacent[u].size(); i++) {
int v = adjacent[u][i];

if (!visited[v] && v != p) {
dfs2(v, u, dv + dp[u] - dp[v]);
}
}
}
}

void Sieve() {
for (int i = 1; i <= 100000; i++) {
prime[i] = true;
}

prime[1] = false;

for (int i = 2; i * i <= 100000; i++) {
if (prime[i]) {
for (int j = i * i; j <= 100000; j += i) {
prime[j] = false;
}
}
}
}

int main() {
Sieve();

int n;
cin >> n;
assert(1 <= n && n <= 100000);

for (int i = 0; i < n - 1; i++) {
int u, v;
cin >> u >> v;
assert(1 <= u && u <= n);
assert(1 <= v && v <= n);

adjacent[u].push_back(v);
adjacent[v].push_back(u);
}

dfs1(1);
for (int i = 1; i <= n; i++) visited[i] = false;

dfs2(1, 0, 0);

cout << answer << endl;
}

Sprinklr โœ…
(Search Engine)