There is a river that runs horizontally through an area. There are a set of cities above and below the river. Each city above the river is matched with a city below the river, and you are given this matching as a set of pairs.
You are interested in building a set of bridges across the river to connect the largest number of the matching pairs of cities, but you must do so in a way that no two bridges intersect one another.
I am sorting the first set and then finding the largest increasing subsequence from second set despite trying all test cases. I am getting wrong answer. Please help if there is something wrong with the approach or any test case i am missing.