JD Group Interview Question

max second query