Solved Daily Coding Problem #1403 [Hard], asked by Two Sigma. Tools used: Microsoft VS Code IDE, Apple Swift, LLVM compiler.