HashedIn by Deloitte Interview Question

DSA Question 1.2 Sum 2.4 Sum 3. Next Greater Element