allcoding1_official
106K subscribers
765 photos
2 videos
73 files
758 links
Download Telegram
int main() {
ll N;
cin >> N;

vector<ll> u(N);
for(ll i = 0; i < N; ++i) {
cin >> u[i];
}

ll M, X;
cin >> M >> X;

vector<vector<ll>> a(N);
for(ll i = 0; i < M; ++i) {
ll x, y;
cin >> x >> y;
a[x].push_back(y);
a[y].push_back(x);
}

vector<bool> v(N, false);
queue<ll> q;
q.push(0);
v[0] = true;

ll m = 0;
while(!q.empty()) {
ll s = q.size();
ll us = 0;
for(ll i = 0; i < s; ++i) {
ll n = q.front();
q.pop();
us += u[n];
for(ll nb : a[n]) {
if(!v[nb]) {
q.push(nb);
v[nb] = true;
}
}
}
m = max(m, us);
}

cout << m << endl;

return 0;
}



apartment

@allcoding1_official
👍1
if not intervals:
        return 0
   
    intervals.sort(key=lambda x: x[0])  # Sort intervals based on start points
    merged_intervals = [intervals[0]]  # Initialize merged intervals with the first interval
   
    for interval in intervals[1:]:
        prev_interval = merged_intervals[-1]
       
        if interval[0] <= prev_interval[1]:  # If overlapping with previous interval
            prev_interval[1] = max(prev_interval[1], interval[1])  # Merge intervals
        else:
            merged_intervals.append(interval)  # Add non-overlapping interval
   
    total_length = sum(end - start for start, end in merged_intervals)
    return total_length

# Example usage:
intervals = [(1, 3), (2, 6), (8, 10), (15, 18)]
total_length_covered = merge_intervals(intervals)
print("Total length covered after merging overlapping intervals:", total_length_covered)
👍5
Forwarded from allcoding1_official
🎯Atos Is Hiring

Degree:- Any Graduate
Batch:- 2019, 2020, 2021, 2022, 2023 & 2024

Apply Now:- https://www.allcoding1.com/2024/02/atos-off-campus-drive-for-any-graduate.html


Telegram:- @allcoding1_official
👍1
Forwarded from allcoding1_official
🎯SAS Off Campus Drive 2024 – Associate Software Engineer – Freshers | Rs 4-8 LPA

Job Role : Associate Software Developer
Qualification : B.E/B/Tech/M.E. / M.Tech
Experience : Freshers
Job Location : Pune
Package : Rs 4-8 LPA

Apply Now:- https://www.allcoding1.com/2024/02/sas-off-campus-drive-2024-associate_9.html?m=1

Telegram:- @allcoding1_official
Forwarded from allcoding1_official
🎯 Microsoft Bulk Hiring 2024 | For Software Engineer

Degree:- BE, B Tech, BA, B COM, BBA, BSC, BCA, ME, M Tech, MCA, MA, M COM, MSC, Any Graduate
Batch:- 2018, 2019, 2020, 2021, 2022, 2023 ,2024 & 2025

Apply now:- https://www.allcoding1.com/2024/02/microsoft-bulk-hiring-2024-for-software.html

Telegram:- @allcoding1_official
1
Forwarded from allcoding1_official
🎯Tech Mahindra Off Campus drive

Job Role Associate Software Engineer
Qualification B.E/B.Tech/MCA/M.Sc
Experience Freshers
Batch 2022/2023
Salary Rs.3.25 LPA & 5.5LPA (for super coders)
Job Location Across India
Venue Location Virtual(Online)
Last Date 4 February 2024

Apply now:- https://www.allcoding1.com/2024/02/tech-mahindra-off-campus-drive-2024.html?m=1

Telegram:- @allcoding1_official
1👍1
Deloitte exam verbal
1) CBDA

2) false

3) At( fill in the blanks 4) In a corner

5) RPQS

6) down

7)He trades both precious and non-precious elements


8) The men yelled in her face

9) in
👍1
Next section
1) BUSMUF
2) KXVTL
3) D
4) CANNOT BE DETERMINED
5) E WA SITTING FRONT OF I
6) both 1 and 3
7) 3
👍1
Nine person

8) H
👍5
❤‍🔥1👍1
#include <stdio.h>

struct Triangle {
    int side1;
    int side2;
    int side3;
};

int IdentifyTriangle(struct Triangle list[], int n) {
    if (list == NULL) {
        return -1;
    }

    int scaleneCount = 0;
    int isoscelesCount = 0;
    int notTriangleCount = 0;

    for (int i = 0; i < n; i++) {
        int s1 = list[i].side1;
        int s2 = list[i].side2;
        int s3 = list[i].side3;
        if ((s1 + s2 > s3) && (s1 + s3 > s2) && (s2 + s3 > s1)) {
            if (s1 != s2 && s2 != s3 && s1 != s3) {
                scaleneCount++;
            }
            else if (s1 == s2 s2 == s3 s1 == s3) {
                isoscelesCount++;
            }
        } else {
            notTriangleCount++;
        }
    }

    return (3 * scaleneCount) - (isoscelesCount + notTriangleCount);
}

Identify triangles

@allcoding1_official
👍8
int countBracketSequence(string s)
{
    int sum = 0;
    int n = s.size();
    for (int i = 0; i < n; i++)
    {
        if (s[i] == '(')
        {
            sum++;
        }
        else
        {
            sum--;
        }
    }
    int ans;
    if(sum!=1 && sum!=-1)
    {
        return 0;
    }
    if (sum < 0)
    {
        sum = 0;
        for (int i = 0; i < n; i++)
        {
            if (s[i] == '(')
            {
                sum++;
            }
            else
            {
                sum--;
            }
            if (sum < 0)
            {
                ans = i + 1;
                break;
            }
        }
    }
    else
    {
        sum = 0;
        int cnt = 0;
        for (int i = n - 1; i >= 0; i--)
        {
            if (s[i] == ')')
            {
                sum++;
            }
            else
            {
                sum--;
            }

            if (sum < 0)
            {
                ans = cnt + 1;
                break;
            }
            cnt++;
        }
    }

    return ans;
}

Bracket Sequence

@allcoding1_official
👍6