ch
Feedback
Coding | EXAMS | IBM ACCENTURE | VIRTUSA | IBM | AMAZON | TCS | EPAM | WILEY EDGE | TECH MAHINDRA | JPMORGAN | HCL | WIPRO

Coding | EXAMS | IBM ACCENTURE | VIRTUSA | IBM | AMAZON | TCS | EPAM | WILEY EDGE | TECH MAHINDRA | JPMORGAN | HCL | WIPRO

前往频道在 Telegram

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

显示更多
3 367
订阅者
-124 小时
-127
-4630
帖子存档
import java.util.*; public class Solution {     static int[] buildingBlocks(int n, int m, int[][] links, int[] a, int k, int[] d) {         // Write your code here.         int[] ans = new int[k];         List> adj = new ArrayList<>();         for(int i = 0; i < n; i++) adj.add(new HashSet<>());         for(int i = 0; i < m; i++){             adj.get(links[i][0]).add(links[i][1]);             adj.get(links[i][1]).add(links[i][0]);         }         Set decay = new HashSet<>();         for(int i = 0; i < k; i++){             if(i != 0){                 removeNode(adj, d[i - 1]);                 decay.add(d[i - 1]);             }             ans[i] = solve(adj, decay, a);                     }         return ans;     }     static void removeNode(List> adj, int node){         for(int i = 0; i < adj.size(); i++){             Set curr = adj.get(i);             if(curr.contains(node)) curr.remove(node);         }     }     static int solve(List> adj, Set decay, int[] a){         int ans = 0;         int[] visited = new int[adj.size()];         for(int i = 0; i < adj.size(); i++){             if(decay.contains(i)) continue;             else if(visited[i] == 0){                 ans = Math.max(ans, dfs(adj, i, visited, a));             }         }         return ans;     }     static int dfs(List> adj, int curr, int[] visited, int[] a){         visited[curr] = 1;         int ans = a[curr];         Set set = adj.get(curr);         for(int i : set){             if(visited[i] == 0){                 ans ^= dfs(adj, i, visited, a);             }         }         return ans;     } }

*Fighting traffic code!!* int getTotalFun(int n, int m, const vector>& graph, const vector& f, int tolerance) {     vector visited(n, 0);     int totalFun = 0;     queue q;     q.push(0);     visited[0] = 1;     while (!q.empty()) {         int city = q.front();         q.pop();         totalFun |= f[city];         for (int neighbor : graph[city]) {             if (visited[neighbor] == 0 && tolerance >= 0) {                 q.push(neighbor);                 visited[neighbor] = 1;             }         }     }     return totalFun; } int fightingTraffic(int n, int m, vector> &roads, vector &t, vector &f, int x) {     // Write your code here.         int low = 0; // Minimum traffic tolerance     int high = 1e9; // Maximum traffic tolerance     int result = -1;     while (low <= high) {         int mid = low + (high - low) / 2;         vector> graph(n);         for (int i = 0; i < m; i++) {             int city1 = roads[i][0];             int city2 = roads[i][1];             int traffic = t[i];             if (traffic <= mid) {                 graph[city1].push_back(city2);                 graph[city2].push_back(city1);             }         }         int totalFun = getTotalFun(n, m, graph, f, mid);         if (totalFun >= x) {             result = mid;             high = mid - 1;         } else {             low = mid + 1;         }     }     return result; }

long long superMovement(int n, vector &a, int k) {     // Write your code here.     vector v(k - 1, LLONG_MAX);  // Use LLONG_MAX for long long     long long ans = 0;     int j = 0;     for (int i = 0; i < n - 1; i++) {         if (j == k - 1) {             j = 0;             continue;         }         long long x = abs(a[i] - a[i + 1]);         v[j] = min(v[j], x);         j++;     }     for (auto i : v) {         ans += i;     }     return ans; }

def calculate_xor(nums):     xor_val = 0     for num in nums:         xor_val ^= num     return xor_val def maximum_beauty(A, D, N, M):     blocks = {}     parent = list(range(N))     rank = [1] * N     beauty = []     for i in range(N):         blocks[i] = [A[i]]     def find_parent(x):         if parent[x] != x:             parent[x] = find_parent(parent[x])         return parent[x]     def merge_blocks(x, y):         px = find_parent(x)         py = find_parent(y)         if px == py:             return         if rank[px] > rank[py]:             parent[py] = px             blocks[px].extend(blocks[py])             rank[px] += rank[py]         else:             parent[px] = py             blocks[py].extend(blocks[px])             rank[py] += rank[px]     for i in range(M):         obj1 = i * 2         obj2 = i * 2 + 1         merge_blocks(obj1, obj2)     for decay_obj in D:         beauty.append(calculate_xor(blocks[find_parent(decay_obj)]))         parent_block = find_parent(decay_obj)         parent_block_objs = blocks[parent_block]         parent_block_objs.remove(A[decay_obj])         if not parent_block_objs:             del blocks[parent_block]     return beauty N = int(input("Enter the number of objects (N): ")) M = int(input("Enter the number of object links (M): ")) print("Enter the values of the objects:") A = [int(input()) for _ in range(N)] K = int(input("Enter the order of object decay (K): ")) print("Enter the indices of the objects in the order of decay:") D = [int(input()) for _ in range(K)] result = maximum_beauty(A, D, N, M) print("Maximum beauty of blocks before object decay:", *result) building block

int terminalDefence(int n, int m, const vector& a, const vector& h, const vector& b, int k) {     vector> monsters;     for (int i = 0; i < m; i++) {         monsters.push_back({a[i], h[i]});     }     sort(monsters.begin(), monsters.end());     for (int i = 0; i < n; i++) {         int sentinelPos = b[i];         auto it = lower_bound(monsters.begin(), monsters.end(), make_pair(sentinelPos, 0));         if (it == monsters.end())             return 0;         int monsterPos = it->first;         int monsterHealth = it->second;         if (monsterPos == sentinelPos) {             if (monsterHealth <= k)                 monsters.erase(it);             else                 it->second -= k;         } else {             if (it == monsters.begin())                 return 0;             it--;             monsterPos = it->first;             monsterHealth = it->second;             if (monsterHealth <= k)                 monsters.erase(it);             else                 it->second -= k;         }     }     return monsters.empty() ? 1 : 0; }

Directed Soldier int directedSoldiers(int n, vector &a) {     // Write your code here.     int d=0;     vector p, p1;     vector b = a;     reverse(b.begin(), b.end());     int k=0;     for (int i = 0; i < n; i++) {         if (b[i]==0) {             k++;         }         p1.push_back(k);     }     for (int i = 0; i < n; i++) {         if (a[i] == 1) {             d += 1;         }         p.push_back(d);     }     reverse(p1.begin(), p1.end());     p1.push_back(0);     int res = count(a.begin(), a.end(), 0);     for (int i = 0; i < n; i++) {         int x = p[i] + p1[i + 1];         res = min(res, x);     }     return res;      }

Hello everyone mostly all codes available Only msg me if u want paid help. Contact @IHATEU_183👨‍💻

Any  campus placement or Offcampus Exam. Help available in All exams. Book your slot.👨‍💻 Contact @IHATEU183 ❤️ Its paid ✅ 100% clearance guarantee 🔥🔥 Share @Coding_000 ❤️

Any one want projects -mini or Major 😊  Unique project💥💥 Domain AI/ML contact -@ILOVEU_143 ❤️ Anyone need help in GRE and TOFEL, GMAT, DUOLINGO Exam help 👨‍💻👨‍💻 SOP , LOR✍📝 Note -paid 🤑 share✅ share ✅@Coding_000

Guys share the screenshot in large groups and share with your friends ✅ @Coding_000❤️ I don`t see anyone sharing 😢