7 years ago Hint to begin with. Find maximum value and sort subarrays in the left and in the right. Count eficienly (subarrays are sorted) how many pairs fulfill the condition. Repeat recursively this operation in right and left subarrays....
Hire TalentFind remote jobs Find Your Dream Job Discover exciting roles at fast growing startups, tailored to your unique profile. Get started with Flexiple now!