Microsoft Interview Question

DSA related problems. Medium level.