Tap here to switch tabs
Problem
Submissions

Problem: Length of the Longest Increasing Path

med
30 min
Try to solve the Length of the Longest Increasing Path problem.

Statement

You are given a 22D array of integers coordinates of size nn, where coordinates[i] =[xi,yi]= [x_i, y_i] represents a point on a 22D plane, and an integer k.

A sequence of points is called an increasing path if for any two consecutive points (xi,yi)(x_i, y_i) and (xi+1,yi+1)(x_{i+1}, y_{i+1}) in the sequence, both xi<xi+1x_i < x_{i+1} and yi<yi+1y_i < y_{i+1} hold.

Return the maximum length of an increasing path that contains the point coordinates[k].

Constraints:

  • 1≤n==1 \leq n == coordinates.length ≤105\leq 10^5

  • coordinates[i].length ==2== 2

  • 0≤0 \leq coordinates[i][0], coordinates[i][1] ≤109\leq 10^9

  • All elements in coordinates are distinct.

  • 0≤0 \leq k ≤n−1\leq n - 1

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Length of the Longest Increasing Path

med
30 min
Try to solve the Length of the Longest Increasing Path problem.

Statement

You are given a 22D array of integers coordinates of size nn, where coordinates[i] =[xi,yi]= [x_i, y_i] represents a point on a 22D plane, and an integer k.

A sequence of points is called an increasing path if for any two consecutive points (xi,yi)(x_i, y_i) and (xi+1,yi+1)(x_{i+1}, y_{i+1}) in the sequence, both xi<xi+1x_i < x_{i+1} and yi<yi+1y_i < y_{i+1} hold.

Return the maximum length of an increasing path that contains the point coordinates[k].

Constraints:

  • 1≤n==1 \leq n == coordinates.length ≤105\leq 10^5

  • coordinates[i].length ==2== 2

  • 0≤0 \leq coordinates[i][0], coordinates[i][1] ≤109\leq 10^9

  • All elements in coordinates are distinct.

  • 0≤0 \leq k ≤n−1\leq n - 1