Google Online challenge -Internship 2021( Today's round questions)

Nope buddy

I found a similar problem on HackerRank. Look at this - Sum of all Distances - HackerRank

Hey @gopalagg , I have tried first problem today by using transitive closure method, I want to know whether this logic works or not? Here is my code https://ideone.com/UqBH3u

In Question 2, do we actually need sparse table, we can just use sliding window approach with 2 pointers first at ‘i’ then second and ‘i+k’ if we move 1 unit to right in array we add A[i+k+1]*k+max(A[i+k+1], previous max) and subtract A[i]*k+prevmax