MathWorks Interview Question

leet code graph style question