First question is exactly same as https://leetcode.com/problems/maximal-network-rank/ Second one is similar to https://leetcode.com/problems/unique-paths-iii/
Got 70 min to solve these