Goldman Sachs Interview Question

leetcode questions about binary array