Hard
You are given a list grid of envelopes where grid[i] = [w, h] is the width and height of envelope i. One envelope fits inside another only if both its width and height are strictly greater. Return the maximum number of envelopes you can nest (Russian doll style).
Input: envelopes = [[5,4],[6,4],[6,7],[2,3]] Output: 3
Input: envelopes = [[1,1],[1,1],[1,1]] Output: 1