maxLeft and maxRight of the same length as the input array nums.maxLeft with the maximum value seen so far from the left, starting from the second element.maxRight with the maximum value seen so far from the right, starting from the second-to-last element.maxTripletValue to store the maximum value of any triplet found.i, calculate the triplet value using maxLeft[i - 1], nums[i], and maxRight[i + 1].maxTripletValue if the current triplet value is greater.maxTripletValue if it is positive, otherwise return 0.