Tough and vast problem


#1

Genuinely MindBoggling problem…
Huge ad vast corner cases.
This is a Leetcode HARD level problem and only 300 points?