Given a matrix of integers **A** of size **N x 2** describing dimensions of **N** envelopes,

where **A[i][0]** denotes the height of the **i ^{th}** envelope and

One envelope can fit into another

if and only if both the width and height of one envelope is greater than the width and height of the other envelope.

Find the maximum number of envelopes you can put one inside other.

**Input Format**

```
The only argument given is the integer matrix A.
```

**Output Format**

```
Return the maximum number of envelopes you can put one inside other.
```

**Constraints**

```
1 <= N <= 100000
1 <= A[i][0], A[i][1] <= 10^9
```

**For Example**

```
Input 1:
A = [ [5, 4]
[6, 4]
[6, 7]
[2, 3] ]
Output 1:
3
Explanation 1:
Step 1: put [2, 3] inside [5, 4]
Step 2: put [5, 4] inside [6, 7]
Input 2:
A = A : [ [8, 9]
[8, 18] ]
Output 2:
1
Explanation 2:
No envelopes can be put inside any other so answer is 1.
```

NOTE:You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a doubt? Checkout Sample Codes for more details.

Sign Up

to access hints and editorial solutions for**Russian Doll Envelopes**

to access hints and editorial solutions for

Loading...