Tap here to switch tabs
Problem
Submissions

Problem: Maximum Length of Pair Chain

med
30 min
Try to solve the Maximum Length of Pair Chain problem.

Statement

You are given an array of nn pairs pairs where pairs[i] = [lefti,righti][left_i, right_i] and lefti<rightileft_i < right_i.

A pair p2=[c,d]p_2 = [c, d] can follow another pair p1=[a,b]p_1 = [a, b] to form a chain if and only if b<cb < c. You can select pairs in any order to construct the chain.

Return the maximum length of a chain that can be formed.

Constraints:

  • n ==== pairs.length

  • 1≤1 \leq n ≤1000\leq 1000

  • −1000≤lefti<righti≤1000-1000 \leq left_i < right_i \leq 1000

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Maximum Length of Pair Chain

med
30 min
Try to solve the Maximum Length of Pair Chain problem.

Statement

You are given an array of nn pairs pairs where pairs[i] = [lefti,righti][left_i, right_i] and lefti<rightileft_i < right_i.

A pair p2=[c,d]p_2 = [c, d] can follow another pair p1=[a,b]p_1 = [a, b] to form a chain if and only if b<cb < c. You can select pairs in any order to construct the chain.

Return the maximum length of a chain that can be formed.

Constraints:

  • n ==== pairs.length

  • 1≤1 \leq n ≤1000\leq 1000

  • −1000≤lefti<righti≤1000-1000 \leq left_i < right_i \leq 1000