Tap here to switch tabs
Problem
Submissions

Problem: Minimum Time for K Connected Components

med
30 min
Try to solve the Minimum Time for K Connected Components problem.

Statement

You are given an integer n, representing the number of nodes in an undirected graph with nodes numbered from 00 to n −1- 1. You are also given an integer k and a 22D integer array edges, where edges[i] =[ui,vi,timei]= [u_i, v_i, time_i] indicates that an undirected edge connects node uiu_i and node viv_i, which gets removed at time timeitime_i.

At time 00, all edges in edges exist in the graph. As time increases, each edge is removed at its designated time.

Return the minimum time needed for the graph to contain at least k connected components.

Constraints:

  • 1≤1 \leq n ≤105\leq 10^5

  • 0≤0 \leq edges.length ≤105\leq 10^5

  • edges[i] =[ui,vi,timei]= [u_i, v_i, time_i]

  • 0≤ui,vi<0 \leq u_i, v_i < n

  • ui≠viu_i \neq v_i

  • 1≤timei≤1091 \leq time_i \leq 10^9

  • 1≤1 \leq k ≤\leq n

  • There are no duplicate edges.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Minimum Time for K Connected Components

med
30 min
Try to solve the Minimum Time for K Connected Components problem.

Statement

You are given an integer n, representing the number of nodes in an undirected graph with nodes numbered from 00 to n −1- 1. You are also given an integer k and a 22D integer array edges, where edges[i] =[ui,vi,timei]= [u_i, v_i, time_i] indicates that an undirected edge connects node uiu_i and node viv_i, which gets removed at time timeitime_i.

At time 00, all edges in edges exist in the graph. As time increases, each edge is removed at its designated time.

Return the minimum time needed for the graph to contain at least k connected components.

Constraints:

  • 1≤1 \leq n ≤105\leq 10^5

  • 0≤0 \leq edges.length ≤105\leq 10^5

  • edges[i] =[ui,vi,timei]= [u_i, v_i, time_i]

  • 0≤ui,vi<0 \leq u_i, v_i < n

  • ui≠viu_i \neq v_i

  • 1≤timei≤1091 \leq time_i \leq 10^9

  • 1≤1 \leq k ≤\leq n

  • There are no duplicate edges.