Two coding questions | 60 minutes
Question 1:


Question 2 :



I figured out a O(n^2) approach for question 1 but didn't implement as i knew that would give TLE.
All the numbers greater than/equal to (a-1)* a can be formed by a and a+1. However a linear solution is expected as seen from the constraints.
Please help me with the intuition/hint to solve the first one.
Spent a lot of time on question 1 and didn't even try the question 2.