bugl
bugl
HomeLearnPatternsPathsSearchPremium
HomeLearnPatternsPaths
MediumTreesLC 1257

Smallest Common Region

You are given some lists of regions where the first region of each list includes all other regions in that list. Naturally, if a region x contains another region y then x is bigger than y. Also, by definition, a region x contains itself. Given two regions: region1 and region2, return the smallest region that contains both of them. If you are given regions r1, r2, and r3 such that r1 includes r3, it is guaranteed there is no r2 such that r2 includes r3. It is guaranteed the smallest region exists.

Asked at 1 company
Airbnb
Hints
  • 1.Think about which data structure fits best
  • 2.Consider the time complexity of your approach
  • 3.Look for patterns in the constraints
LeetCode